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

CommandOptionDescription
docker stop-s, --signal stringSignal to send to the container
docker stop-t, --timeout intSeconds to wait before forcibly stopping the container
docker start-a, --attachAttach to the container's STDOUT/STDERR and forward signals
docker start--checkpoint stringRestore from the specified checkpoint
docker start--checkpoint-dir stringUse a custom checkpoint storage directory
docker start--detach-keys stringOverride the key sequence used to detach from the container
docker start-i, --interactiveAttach the container's STDIN
docker restart-s, --signal stringSignal to send to the container
docker restart-t, --timeout intSeconds to wait before forcibly stopping the container
docker kill-s, --signal stringSignal 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
  • web stopped after 0.50 seconds with a status of Exited (0): nginx exited normally after receiving SIGTERM.
  • sleeper took 10.44 seconds and has a status of Exited (137): sleep is 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, --timeout in docker stop --help to 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 -a lists stopped containers. uses-redis and registry are 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 start starts the stopped web container. docker restart -t 2 restarts it with a 2-second timeout.
  • docker kill sleeper fails on a stopped container, and the error says the container is not running. Run start before kill and both commands succeed.
  • After kill, sleeper shows Exited (137), while web shows Up.

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 pause pauses all processes in the container. The status column shows (Paused).
  • docker exec fails while the container is paused, and the error says to unpause it first. docker unpause resumes 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 HUP sends the specified signal to the container. Here, the web2 logs clearly show that it received SIGHUP and is reloading.
  • docker logs --tail 3 limits the output to the three most recent lines. The other example merges stderr into stdout, then uses grep to 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.

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