docker stop
Asks a running container to shut down cleanly, then forces it if it does not.
In more detail
Docker sends SIGTERM, or the image's configured stop signal, to the main process, waits 10 seconds by default, then sends SIGKILL. The container and its data stay, ready to start again, unless it was run with --rm. If stop always takes the full 10 seconds, the process is ignoring the signal, often because it runs as PID 1 through a shell.
Examples
docker stop taskapi-demodocker stop m07l03-b3Related terms
- SIGTERM — The signal that politely asks a process to finish its work and exit.
- SIGKILL — The signal that ends a process immediately; it cannot be caught or ignored.
- graceful shutdown — Stopping a service in an orderly way: finish current work, close connections, then exit.
- init process — The first process started on a system or in a container, with process ID 1 and special duties.
- docker start — Starts a container that already exists, keeping its writable layer and settings.
- docker rm — Deletes a stopped container and its writable layer; the image stays.
Taught in
- Run, Stop, Restart And Remove A Container — Docker Architecture & Production Containers
- Run The Spine Service And Publish Its Port — Docker Architecture & Production Containers
- CMD, ENTRYPOINT, USER And Process Signals — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Diagnose Crashes, Resource Limits And Unhealthy Containers — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- Losing A Broker — Apache Kafka & Event Streaming