docker stop: Gracefully Stop Containers
Stop a container the polite way: SIGTERM, then SIGKILL after a timeout.
docker stop stops a running container by sending SIGTERM and, after a grace period, SIGKILL. This page covers the timeout and stopping many containers in CI cleanup.
What it does
docker stop sends SIGTERM to the main process, waits (default 10s, or -t seconds), then sends SIGKILL if it has not exited. This lets apps shut down cleanly, unlike docker kill.
Common usage
docker stop web
docker stop -t 30 web # 30s grace period
docker stop $(docker ps -q) # stop all runningCommon errors in CI
If docker stop $(docker ps -q) errors with "docker stop requires at least 1 argument" it means no containers are running - guard it in CI cleanup steps so an empty list does not fail the job (e.g. only run when docker ps -q is non-empty). A container that ignores SIGTERM takes the full grace period before SIGKILL, slowing cleanup; lower -t or use docker kill if you do not need graceful shutdown.