docker_practice/container/stop.md

18 lines
1.0 KiB
Markdown
Raw Normal View History

##終止容器
2014-11-19 17:04:25 +00:00
可以使用 `docker stop` 來終止一個執行中的容器。
2014-09-15 13:25:36 +00:00
此外當Docker容器中指定的應用終結時容器也自動終止。
2014-11-24 14:37:20 +00:00
例如對於上一章節中只啟動了一個終端機的容器,使用者透過 `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
```
2014-11-24 14:37:20 +00:00
處於終止狀態的容器,可以透過 `docker start` 命令來重新啟動。
2014-11-22 07:25:43 +00:00
此外,`docker restart` 命令會將一個執行中的容器終止,然後再重新啟動它。