containers
docker stop
Gracefully stops one or more running containers by sending SIGTERM and then SIGKILL after a timeout. Use docker kill for an immediate SIGKILL.
docker stop [OPTIONS] CONTAINER [CONTAINER...] Common flags
| Flag | Purpose |
|---|---|
| -t, --timeout | Seconds to wait before killing (default 10) |
| -s, --signal | Signal to send to the container (default SIGTERM) |
| CONTAINER | One or more container names or IDs to stop |
Examples
docker stop web Graceful stop with default 10s grace period
docker stop -t 30 db Allow 30 seconds for graceful shutdown
docker stop $(docker ps -q) Stop every running container
docker stop web api worker Stop several containers in one call
Gotcha
Apps ignoring SIGTERM get SIGKILL'd after -t seconds — long-running graceful shutdowns need a larger timeout. Docker sends signals to PID 1, so shell-wrapped entrypoints often swallow them; use exec form in Dockerfile CMD.
Related commands
docker start
Starts one or more previously created or stopped containers using their existing configuration. Unlike docker run it does not create a new container.
docker restart
Stops and then starts one or more containers, preserving their configuration. Equivalent to docker stop followed by docker start.
docker rm
Removes one or more stopped containers from the host. Use -f to force-remove a running container.
docker ps
Lists containers along with their status, ports, and identifiers. By default it shows only running containers unless -a is passed.
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs