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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

docker stop [OPTIONS] CONTAINER [CONTAINER...]

Parameters

ParameterDescription
-t SECONDS Seconds to wait before killing (default 10).
-s SIGNAL Signal to send instead of SIGTERM.

Examples

A process that handles SIGTERM
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.

A process that ignores it gets SIGKILL (137)
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.

Was this page helpful?