docker stop
Stop a running container, start it again with everything kept, or restart it after a config change.
>_ Try it: a simulated Linux, right herenothing runs on your computer
Loading the terminal…
Examples
-
docker stop web -
docker ps -a -
docker start web -
docker restart site -
docker stop web site -
docker ps
How it works
docker stop NAME asks the container to shut down cleanly (then forces it after 10 seconds). It isn't deleted: docker ps -a still shows it as Exited, with its files and settings.
docker start NAME brings the same container back; docker restart NAME is stop + start in one command.
Syntax
docker stop CONTAINER... | docker start CONTAINER... | docker restart CONTAINER...
Options
| Option | What it does |
|---|---|
CONTAINER... | one or more containers, by name or ID |
docker start | start a stopped container again |
docker restart | stop and start it |
Good to know
- Stopping keeps the container;
docker rmdeletes it. Data you need to keep belongs in a volume (-v), not in the container. - The options of
docker run(ports, name, -e) can't be changed by a restart: recreate the container for that.