Contents
Docker stop, start, restart, and kill tutorial: Stop and restart containers
Use docker stop, start, restart, kill, pause, and unpause to control a container's runtime state. For the complete container lifecycle, see Container lifecycle.
Syntax
docker stop [OPTIONS] CONTAINER [CONTAINER...]
docker start [OPTIONS] CONTAINER [CONTAINER...]
docker restart [OPTIONS] CONTAINER [CONTAINER...]
docker kill [OPTIONS] CONTAINER [CONTAINER...]
docker pause CONTAINER [CONTAINER...]
docker unpause CONTAINER [CONTAINER...]
Options
| Command | Option | Description |
|---|---|---|
docker stop | -s, --signal string | Signal to send to the container |
docker stop | -t, --timeout int | Seconds to wait before forcibly stopping the container |
docker start | -a, --attach | Attach to the container's STDOUT/STDERR and forward signals |
docker start | --checkpoint string | Restore from the specified checkpoint |
docker start | --checkpoint-dir string | Use a custom checkpoint storage directory |
docker start | --detach-keys string | Override the key sequence used to detach from the container |
docker start | -i, --interactive | Attach the container's STDIN |
docker restart | -s, --signal string | Signal to send to the container |
docker restart | -t, --timeout int | Seconds to wait before forcibly stopping the container |
docker kill | -s, --signal string | Signal to send to the container |
The pause and unpause descriptions list no additional options. You can also run stop, start, restart, kill, and pause as docker container subcommands.
Examples
Stop timeout and exit status
$ time docker stop web
web
real 0m 0.50s
user 0m 0.00s
sys 0m 0.01s
$ time docker stop sleeper
sleeper
real 0m 10.44s
user 0m 0.01s
sys 0m 0.01s
$ docker ps -a --format 'table {{.Names}}\t{{.Status}}'
NAMES STATUS
sleeper Exited (137) 1 second ago
web Exited (0) 12 seconds ago
uses-redis Up 51 seconds
registry Up About a minute
webstopped after 0.50 seconds with a status ofExited (0): nginx exited normally after receiving SIGTERM.sleepertook 10.44 seconds and has a status ofExited (137):sleepis PID 1 in the container and does not handle SIGTERM. Docker waits the full default 10 seconds, then sends SIGKILL (137 = 128 + 9). See the explanation of PID 1 in Container lifecycle.- Use
-t, --timeoutindocker stop --helpto set how many seconds to wait before forcibly stopping the container. This example shows the difference between the default wait and forced stop. docker ps -alists stopped containers.uses-redisandregistryare still running.
Start, restart, and kill
$ docker start web
web
$ docker restart -t 2 web
web
$ docker kill sleeper
Error response from daemon: cannot kill container: sleeper: container ebcd31ea947204593383614f0fa2b0b9baba719e4858042e8120b3d544468f20 is not running
$ docker start sleeper && docker kill sleeper
sleeper
sleeper
$ docker ps -a --format 'table {{.Names}}\t{{.Status}}'
NAMES STATUS
sleeper Exited (137) Less than a second ago
web Up 2 seconds
uses-redis Up 54 seconds
registry Up About a minute
docker startstarts the stoppedwebcontainer.docker restart -t 2restarts it with a 2-second timeout.docker kill sleeperfails on a stopped container, and the error says the container is not running. Run start before kill and both commands succeed.- After kill,
sleepershowsExited (137), whilewebshowsUp.
Pause and unpause
$ docker pause web
web
$ docker ps --format 'table {{.Names}}\t{{.Status}}'
NAMES STATUS
web Up 2 seconds (Paused)
uses-redis Up 55 seconds
registry Up About a minute
$ docker exec web nginx -v
Error response from daemon: Container web is paused, unpause the container before exec
$ docker unpause web
web
docker pausepauses all processes in the container. The status column shows(Paused).docker execfails while the container is paused, and the error says to unpause it first.docker unpauseresumes the container.
Send a signal to reload nginx
$ docker kill -s HUP web
web
$ docker logs --tail 3 web
2026/10/25 15:30:32 [notice] 1#1: signal 17 (SIGCHLD) received from 22
2026/10/25 15:30:32 [notice] 1#1: worker process 22 exited with code 0
2026/10/25 15:30:32 [notice] 1#1: signal 29 (SIGIO) received
$ docker kill -s HUP web2
web2
$ docker logs web2 2>&1 | grep -E 'SIGHUP|reconfiguring'
2026/10/25 15:31:00 [notice] 1#1: signal 1 (SIGHUP) received, reconfiguring
2026/10/25 15:31:00 [notice] 1#1: reconfiguring
docker kill -s HUPsends the specified signal to the container. Here, theweb2logs clearly show that it receivedSIGHUPand is reloading.docker logs --tail 3limits the output to the three most recent lines. The other example merges stderr into stdout, then usesgrepto filter the logs.
Container name does not exist
$ docker stop nosuch
Error response from daemon: No such container: nosuch
If the specified container name does not exist, Docker reports No such container.
Related topics
- Container lifecycle
- docker ps command: View container status
- docker exec command: Run a command in a running container
- docker logs command: View container logs
Exercises
Exercise: The sleeper container is stopped. Start it, immediately force it to stop, then list the names and statuses of all containers.
Answer
docker start sleeper && docker kill sleeper
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
FAQ
Why does docker stop sleeper take about 10 seconds?
This docker stop sleeper command took 10.44 seconds, and the resulting status was Exited (137). docker stop --help explains that -t, --timeout sets how many seconds to wait before forcibly stopping the container.
Can you use docker kill on a stopped container?
No. When you run docker kill on the stopped sleeper, Docker reports that the container is not running. Start it with docker start sleeper before you kill it.
Can you use docker exec after pausing a container?
No. In the example, docker exec web nginx -v reports that the container is paused. You must run docker unpause web first.
How do you reload nginx configuration without stopping the container?
Send HUP to the container with docker kill -s HUP web2. The logs show SIGHUP received, reconfiguring.
Updated October 26, 2026