docker ps

1 概述

用于列出容器清单。

2 语法大纲

docker ps --help
//屏幕输出:
Usage:  docker ps [OPTIONS]

List containers

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print containers using a Go template
  -n, --last int        Show n last created containers (includes all states) (default -1)
  -l, --latest          Show the latest created container (includes all states)
      --no-trunc        Don't truncate output
  -q, --quiet           Only display container IDs
  -s, --size            Display total file sizes

3 参数说明

参数 说明
-a, --all 显示所有容器 (默认显示刚刚运行) 。
-f, --filter filter 根据提供的条件过滤输出。
-n, --last int 显示最后创建的容器 (包括所有状态) 。
--latest, -l 显示最新创建的容器 (包括所有状态)。
--no-trunc 不要截断输出。
--quiet, -q 只显示数字 ID 。
--size, -s 显示文件大小。

4 示例显示所有容器

  1. 显示正在运行、暂停、停止等运行状态的容器清单。
docker ps -a
//屏幕输出:
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
  1. 返回信息的说明。
字段 说明
CONTAINER ID 容器 ID。
IMAGE 使用的镜像。
COMMAND 启动容器时运行的命令。
CREATED 容器的创建时间。
STATUS 容器状态。

编者注:STATUS 状态有 7 种。

-   created(已创建)
-   restarting(重启中)
-   running(运行中)
-   removing(迁移中)
-   paused(暂停)
-   exited(停止)
-   dead(死亡)