6.1.3 Container Stopping
A focused guide to Container Stopping, connecting core concepts with practical Docker and container operations.
Container stopping is the process of terminating a running container's main process, transitioning the container from a running state into a stopped state while preserving its writable layer and configuration, distinct from removing the container entirely.
Stopping a Container
The docker stop command sends a termination signal to the container's main process, allowing it an opportunity to shut down gracefully before being forcibly killed if it doesn't exit in time.
docker stop myapp
What Happens to the Container After Stopping
A stopped container retains its writable layer, configuration, and name — it can be inspected, restarted, or removed, but its main process is no longer running and it consumes no CPU or memory while in this state.
docker stop myapp
docker ps -a
The stopped container still appears in this listing, distinguishing it from a removed container, which would not appear at all.
Restarting a Stopped Container
A stopped container can be started again, resuming with whatever state was present in its writable layer at the time it was stopped.
docker start myapp
Forcibly Killing a Container Instead of Stopping It Gracefully
For situations where an immediate termination is needed, without waiting for a graceful shutdown attempt, docker kill immediately terminates the container's main process.
docker kill myapp
This skips the graceful shutdown opportunity docker stop provides, which can be appropriate for a genuinely unresponsive container but risks not allowing the application to clean up properly.
Why Understanding Container Stopping Matters
Recognizing that stopping a container is distinct from removing it — and that a stopped container retains its state and can be restarted — is essential for correctly managing a container's lifecycle without accidentally losing data or unnecessarily recreating containers that could simply have been restarted instead.