docker_practice/container/stop.md
2014-11-18 21:06:39 +08:00

18 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

##終止容器
可以使用 `docker stop` 來終止一個運行中的容器。
此外當Docker容器中指定的應用終結時容器也自動終止。
例如對於上一章節中只啟動了一個終端的容器,用戶通過 `exit` 命令或 `Ctrl+d` 來退出終端時,所創建的容器立刻終止。
終止狀態的容器可以用 `docker ps -a` 命令看到。例如
```
sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ba267838cc1b ubuntu:14.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
98e5efa7d997 training/webapp:latest "python app.py" About an hour ago Exited (0) 34 minutes ago backstabbing_pike
```
處於終止狀態的容器,可以通過 `docker start` 命令來重新啟動。
此外,`docker restart` 命令會將一個運行態的容器終止,然後再重新啟動它。