Merge pull request #309 from khs1994/master

Change command docker ps to docker container ls
pull/368/head
康怀帅 2018-01-16 16:31:05 +08:00 committed by GitHub
commit 4667ffb091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 12 deletions

View File

@ -38,13 +38,13 @@
## 容器相关 ## 容器相关
### 容器退出后,通过 docker ps 命令查看不到,数据会丢失么? ### 容器退出后,通过 docker container ls 命令查看不到,数据会丢失么?
容器退出后会处于终止exited状态此时可以通过 `docker ps -a` 查看。其中的数据也不会丢失,还可以通过 `docker start` 命令来启动它。只有删除掉容器才会清除所有数据。 容器退出后会处于终止exited状态此时可以通过 `docker container ls -a` 查看。其中的数据也不会丢失,还可以通过 `docker start` 命令来启动它。只有删除掉容器才会清除所有数据。
### 如何停止所有正在运行的容器? ### 如何停止所有正在运行的容器?
答:可以使用 `docker kill $(docker ps -q)` 命令。 答:可以使用 `docker kill $(docker container ls -q)` 命令。
### 如何批量清理已经停止的容器? ### 如何批量清理已经停止的容器?

View File

@ -4,7 +4,7 @@
如果要导出本地某个容器,可以使用 `docker export` 命令。 如果要导出本地某个容器,可以使用 `docker export` 命令。
```bash ```bash
$ docker ps -a $ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7691a814370e ubuntu:14.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test 7691a814370e ubuntu:14.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
$ docker export 7691a814370e > ubuntu.tar $ docker export 7691a814370e > ubuntu.tar

View File

@ -9,7 +9,7 @@
终止状态的容器可以用 `docker container ls -a` 命令看到。例如 终止状态的容器可以用 `docker container ls -a` 命令看到。例如
```bash ```bash
docker ps -a docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 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 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 98e5efa7d997 training/webapp:latest "python app.py" About an hour ago Exited (0) 34 minutes ago backstabbing_pike

View File

@ -46,18 +46,18 @@ $ docker build -t myweb:v1 .
$ docker run -d --name web -p 80:80 myweb:v1 $ docker run -d --name web -p 80:80 myweb:v1
``` ```
当运行该镜像后,可以通过 `docker ps` 看到最初的状态为 `(health: starting)` 当运行该镜像后,可以通过 `docker container ls` 看到最初的状态为 `(health: starting)`
```bash ```bash
$ docker ps $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03e28eb00bd0 myweb:v1 "nginx -g 'daemon off" 3 seconds ago Up 2 seconds (health: starting) 80/tcp, 443/tcp web 03e28eb00bd0 myweb:v1 "nginx -g 'daemon off" 3 seconds ago Up 2 seconds (health: starting) 80/tcp, 443/tcp web
``` ```
在等待几秒钟后,再次 `docker ps`,就会看到健康状态变化为了 `(healthy)` 在等待几秒钟后,再次 `docker container ls`,就会看到健康状态变化为了 `(healthy)`
```bash ```bash
$ docker ps $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03e28eb00bd0 myweb:v1 "nginx -g 'daemon off" 18 seconds ago Up 16 seconds (healthy) 80/tcp, 443/tcp web 03e28eb00bd0 myweb:v1 "nginx -g 'daemon off" 18 seconds ago Up 16 seconds (healthy) 80/tcp, 443/tcp web
``` ```

View File

@ -381,7 +381,7 @@ Marathon 的更多 REST API 可以参考本地自带的文档:`http://marathon
任务执行后,也可以在对应 slave 节点上通过 Docker 命令查看容器运行情况,容器将以 `mesos-SLAVE_ID` 开头。 任务执行后,也可以在对应 slave 节点上通过 Docker 命令查看容器运行情况,容器将以 `mesos-SLAVE_ID` 开头。
```sh ```sh
$ docker ps $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1226b4ec8d7d python:3 "/bin/sh -c 'python3 " 3 days ago Up 3 days 0.0.0.0:10000->8080/tcp mesos-06db0fba-49dc-4d28-ad87-6c2d5a020866-S10.b581149e-2c43-46a2-b652-1a0bc10204b3 1226b4ec8d7d python:3 "/bin/sh -c 'python3 " 3 days ago Up 3 days 0.0.0.0:10000->8080/tcp mesos-06db0fba-49dc-4d28-ad87-6c2d5a020866-S10.b581149e-2c43-46a2-b652-1a0bc10204b3
``` ```

View File

@ -35,7 +35,7 @@ nameserver 8.8.8.8
如果用户想要手动指定容器的配置,可以在使用 `docker run` 命令启动容器时加入如下参数: 如果用户想要手动指定容器的配置,可以在使用 `docker run` 命令启动容器时加入如下参数:
`-h HOSTNAME` 或者 `--hostname=HOSTNAME` 设定容器的主机名,它会被写到容器内的 `/etc/hostname``/etc/hosts`。但它在容器外部看不到,既不会在 `docker ps` 中显示,也不会在其他的容器的 `/etc/hosts` 看到。 `-h HOSTNAME` 或者 `--hostname=HOSTNAME` 设定容器的主机名,它会被写到容器内的 `/etc/hostname``/etc/hosts`。但它在容器外部看不到,既不会在 `docker container ls` 中显示,也不会在其他的容器的 `/etc/hosts` 看到。
`--dns=IP_ADDRESS` 添加 DNS 服务器到容器的 `/etc/resolv.conf` 中,让容器用这个服务器来解析所有不在 `/etc/hosts` 中的主机名。 `--dns=IP_ADDRESS` 添加 DNS 服务器到容器的 `/etc/resolv.conf` 中,让容器用这个服务器来解析所有不在 `/etc/hosts` 中的主机名。

View File

@ -9,7 +9,7 @@
```bash ```bash
$ docker run -d -P training/webapp python app.py $ docker run -d -P training/webapp python app.py
$ docker ps -l $ docker container ls -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse
``` ```