docker_practice/container/stop.md
Kang Huaishuai ee26243625
use nginx:alpine as demo
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
2020-08-25 16:54:59 +08:00

20 lines
951 B
Go
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 container stop` 来终止一个运行中的容器
此外 Docker 容器中指定的应用终结时容器也自动终止
例如对于上一章节中只启动了一个终端的容器用户通过 `exit` 命令或 `Ctrl+d` 来退出终端时所创建的容器立刻终止
终止状态的容器可以用 `docker container ls -a` 命令看到例如
```bash
docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ba267838cc1b ubuntu:18.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
```
处于终止状态的容器可以通过 `docker container start` 命令来重新启动
此外`docker container restart` 命令会将一个运行态的容器终止然后再重新启动它