# docker stop: Gracefully Stop Containers

> How docker stop works: sending SIGTERM then SIGKILL, the grace period, stopping multiple containers, and cleanup in CI.

Source: https://latchkey.dev/learn/command-reference/docker-stop-command  
Updated: 2026-06-25

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

```Terminal
docker stop web
docker stop -t 30 web                  # 30s grace period
docker stop $(docker ps -q)            # stop all running
```

## Common 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.

## FAQ

### docker stop: Gracefully Stop Containers?

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 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).

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
