Docker Engine 29 reference · Containers
docker stop Command (Docker CLI)
Stop running containers gracefully: send SIGTERM, wait for the timeout (10 s by default), then SIGKILL.
Docker Engine 29
Syntax
docker stop [OPTIONS] CONTAINER [CONTAINER...]
Parameters
| Parameter | Description |
|---|---|
-t SECONDS |
Seconds to wait before killing (default 10). |
-s SIGNAL |
Signal to send instead of SIGTERM. |
Examples
docker run -d --name rc-ref-stop alpine:3.24 sh -c 'trap "echo got SIGTERM; exit 0" TERM; while true; do sleep 0.2; done' > /dev/null
sleep 1; docker stop rc-ref-stop > /dev/null
docker logs rc-ref-stop
docker inspect rc-ref-stop --format 'exit code {{.State.ExitCode}}'
docker rm rc-ref-stop > /dev/null
Output
got SIGTERM exit code 0
Run this on your computer — see “Get Started” for setup.
docker run -d --name rc-ref-stop2 alpine:3.24 sleep 300 > /dev/null
docker stop -t 1 rc-ref-stop2 > /dev/null
docker inspect rc-ref-stop2 --format 'ignored SIGTERM, killed: exit code {{.State.ExitCode}}'
docker rm rc-ref-stop2 > /dev/null
Output
ignored SIGTERM, killed: exit code 137
Run this on your computer — see “Get Started” for setup.
Related
docker rm· Remove one or more stopped containers and their writable layers; -f stops and removes running ones too.docker run· Create and start a container from an image, with options for ports, environment, volumes, names and cleanup.- The Container Lifecycle · tutorial