NAME 名称

podman-ps - Print out information about containers
podman-ps - 打印有关容器的信息

SYNOPSIS 概要

podman ps [options] podman ps [选项]

podman container ps [options]
podman container ps [选项]

podman container list [options]
podman 容器列表[选项]

podman container ls [options]
podman 容器 ls [选项]

DESCRIPTION 描述

podman ps lists the running containers on the system. Use the --all flag to view all the containers information. By default it lists:
podman ps 列出系统上正在运行的容器。使用--all 标志查看所有容器信息。默认情况下,它列出:

  • container id 容器 ID

  • the name of the image the container is using
    容器使用的镜像名称

  • the COMMAND the container is executing
    容器正在执行的命令

  • the time the container was created
    容器创建的时间

  • the status of the container
    容器的状态

  • port mappings the container is using
    容器正在使用的端口映射

  • alternative names for the container
    容器的替代名称

OPTIONS 选项

--all, -a

Show all the containers, default is only running containers.
显示所有容器,默认仅显示正在运行的容器。

Note: Podman shares containers storage with other tools such as Buildah and CRI-O. In some cases these external containers might also exist in the same storage. Use the --external option to see these external containers. External containers show the ‘storage’ status.
注意:Podman 与 Buildah 和 CRI-O 等其他工具共享容器存储。在某些情况下,这些 external 容器也可能存在于相同的存储中。使用 --external 选项查看这些外部容器。外部容器显示“存储”状态。

--external --外部 ¶

Display external containers that are not controlled by Podman but are stored in containers storage. These external containers are generally created via other container technology such as Buildah or CRI-O and may depend on the same container images that Podman is also using. External containers are denoted with either a ‘buildah’ or ‘storage’ in the COMMAND and STATUS column of the ps output.
显示存储在容器存储中但不受 Podman 控制的外部容器。这些外部容器通常是通过其他容器技术(如 Buildah 或 CRI-O)创建的,并且可能依赖于 Podman 也在使用的相同容器映像。外部容器在 ps 输出的 COMMAND 和 STATUS 列中用 'buildah' 或 'storage' 表示。

--filter, -f

Filter what containers are shown in the output. Multiple filters can be given with multiple uses of the --filter flag. Filters with the same key work inclusive with the only exception being label which is exclusive. Filters with different keys always work exclusive.
过滤输出中显示的容器。可以使用多个 --filter 标志给出多个过滤器。具有相同键的过滤器与唯一例外的 label 一起包含工作。具有不同键的过滤器始终是互斥的。

Valid filters are listed below:
下面列出了有效的过滤器:

Filter

Description

id

[ID] Container’s ID (CID prefix match by default; accepts regex)
[ID] 容器的 ID(默认情况下是 CID 前缀匹配;接受正则表达式)

name

[Name] Container’s name (accepts regex)
[名称] 容器的名称(接受正则表达式)

label

[Key] or [Key=Value] Label assigned to a container
[键] 或 [键=值] 分配给容器的标签

label! 标签!

[Key] or [Key=Value] Label NOT assigned to a container
[键] 或 [键=值] 标签未分配给容器

exited

[Int] Container’s exit code
[整数] 容器的退出代码

status

[Status] Container’s status: ‘created’, ‘exited’, ‘paused’, ‘running’, ‘unknown’
[状态] 容器的状态: '已创建','已退出','已暂停','运行中','未知'

ancestor

[ImageName] Image or descendant used to create container (accepts regex)
[镜像名称] 用于创建容器的镜像或后代(接受正则表达式)

before

[ID] or [Name] Containers created before this container
[ID] 或 [名称] 在此容器之前创建的容器

since

[ID] or [Name] Containers created since this container
自创建此容器以来的[ID]或[名称]容器

volume

[VolumeName] or [MountpointDestination] Volume mounted in container
容器中挂载的[VolumeName]或[MountpointDestination]卷

health

[Status] healthy or unhealthy
[状态]健康或不健康

pod

[Pod] name or full or partial ID of pod
[Pod] Pod 的名称或完整或部分 ID

network

[Network] name or full ID of network
[Network] 网络的名称或完整 ID

until

[DateTime] container created before the given duration or time.
[DateTime] 在给定的持续时间或时间之前创建的容器

--format=format

Pretty-print containers to JSON or using a Go template
将容器漂亮地打印成 JSON 或使用 Go 模板

Valid placeholders for the Go template are listed below:
Go 模板的有效占位符如下所示:

Placeholder

Description

.AutoRemove

If true, containers are removed on exit
如果为真,则容器在退出时被移除

.CIDFile

Container ID File 容器 ID 文件

.Command

Quoted command used 使用引号引起的命令

.Created … .创建…

Creation time for container, Y-M-D H:M:S
容器的创建时间,年-月-日 时:分:秒

.CreatedAt

Creation time for container (same as above)
容器的创建时间(同上)

.CreatedHuman

Creation time, relative 创建时间,相对时间

.ExitCode

Container exit code 容器退出代码

.Exited

“true” if container has exited
如果容器已退出则为“true”

.ExitedAt

Time (epoch seconds) that container exited
容器退出的时间(epoch 秒)

.ExposedPorts … .暴露的端口…

Map of exposed ports on this container
此容器上暴露端口的映射

.ID

Container ID 容器 ID

.Image

Image Name/ID 镜像名称/ID

.ImageID

Image ID 图像 ID

.IsInfra

“true” if infra container
如果是基础设施容器,则为“true”

.Label string .标签字符串

Specified label of the container
容器的指定标签

.Labels … .标签 …

All the labels assigned to the container
分配给容器的所有标签

.Mounts

Volumes mounted in the container
挂载在容器中的卷

.Names

Name of container 容器的名称

.Networks

Show all networks connected to the container
显示连接到容器的所有网络

.Pid

Process ID on host system
主机系统上的进程 ID

.Pod

Pod the container is associated with (SHA)
与容器关联的 Pod(SHA)

.PodName

PodName of the container 容器的 Pod 名称

.Ports

Forwarded and exposed ports
转发和暴露端口

.Restarts

Display the container restart count
显示容器重新启动计数

.RunningFor

Time elapsed since container was started
容器启动后经过的时间

.Size

Size of container 容器大小

.StartedAt

Time (epoch seconds) the container started
容器启动时间(epoch 秒)

.State

Human-friendly description of ctr state
ctr 状态的人性化描述

.Status

Status of container 容器状态

--help, -h --help,-h ¶

Print usage statement 打印使用说明

--last, -n

Print the n last created containers (all states)
打印最后创建的 n 个容器(所有状态)

--latest, -l

Show the latest container created (all states) (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
显示最新创建的容器(所有状态)(此选项在远程 Podman 客户端中不可用,包括 Mac 和 Windows(不包括 WSL2)机器)

--namespace, --ns

Display namespace information
显示命名空间信息

--no-trunc

Do not truncate the output (default false).
不要截断输出(默认为 false)。

--noheading --noheading

Omit the table headings from the listing of containers.
从容器列表中省略表头。

--pod, -p

Display the pods the containers are associated with
显示容器关联的 Pod。

--quiet, -q

Print the numeric IDs of the containers only
仅打印容器的数字 ID

--size, -s --size,-s ¶

Display the total file size
显示总文件大小

--sort=created --sort=created

Sort by command, created, id, image, names, runningfor, size, or status”, Note: Choosing size sorts by size of rootFs, not alphabetically like the rest of the options
按命令、创建时间、ID、镜像、名称、运行时间、大小或状态排序”,注意:选择大小会按照 rootFs 的大小排序,而不是像其他选项一样按字母顺序排序

--sync

Force a sync of container state with the OCI runtime. In some cases, a container’s state in the runtime can become out of sync with Podman’s state. This updates Podman’s state based on what the OCI runtime reports. Forcibly syncing is much slower, but can resolve inconsistent state issues.
强制同步容器状态与 OCI 运行时。在某些情况下,容器在运行时的状态可能与 Podman 的状态不同步。这将根据 OCI 运行时报告的内容更新 Podman 的状态。强制同步速度较慢,但可以解决不一致的状态问题。

--watch, -w

Refresh the output with current containers on an interval in seconds.
每隔几秒刷新输出,显示当前容器。

EXAMPLES 示例

List running containers.
列出正在运行的容器。

$ podman ps
CONTAINER ID  IMAGE                            COMMAND    CREATED        STATUS        PORTS                                                   NAMES
4089df24d4f3  docker.io/library/centos:latest  /bin/bash  2 minutes ago  Up 2 minutes  0.0.0.0:80->8080/tcp, 0.0.0.0:2000-2006->2000-2006/tcp  manyports
92f58933c28c  docker.io/library/centos:latest  /bin/bash  3 minutes ago  Up 3 minutes  192.168.99.100:1000-1006->1000-1006/tcp                 zen_sanderson

List all containers. 列出所有容器。

$ podman ps -a
CONTAINER ID   IMAGE         COMMAND         CREATED       STATUS                    PORTS     NAMES
02f65160e14ca  redis:alpine  "redis-server"  19 hours ago  Exited (-1) 19 hours ago  6379/tcp  k8s_podsandbox1-redis_podsandbox1_redhat.test.crio_redhat-test-crio_0
69ed779d8ef9f  redis:alpine  "redis-server"  25 hours ago  Created                   6379/tcp  k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1

List all containers including their size. Note: this can take longer since Podman needs to calculate the size from the file system.
列出所有容器,包括它们的大小。注意:这可能需要更长的时间,因为 Podman 需要从文件系统计算大小。

$ podman ps -a -s
CONTAINER ID   IMAGE         COMMAND         CREATED       STATUS                    PORTS     NAMES                                                                  SIZE
02f65160e14ca  redis:alpine  "redis-server"  20 hours ago  Exited (-1) 20 hours ago  6379/tcp  k8s_podsandbox1-redis_podsandbox1_redhat.test.crio_redhat-test-crio_0  27.49 MB
69ed779d8ef9f  redis:alpine  "redis-server"  25 hours ago  Created                   6379/tcp  k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1         27.49 MB

List all containers, running or not, using a custom Go format.
列出所有容器,无论是否正在运行,使用自定义的 Go 格式。

$ podman ps -a --format "{{.ID}}  {{.Image}}  {{.Labels}}  {{.Mounts}}"
02f65160e14ca  redis:alpine  tier=backend  proc,tmpfs,devpts,shm,mqueue,sysfs,cgroup,/var/run/,/var/run/
69ed779d8ef9f  redis:alpine  batch=no,type=small  proc,tmpfs,devpts,shm,mqueue,sysfs,cgroup,/var/run/,/var/run/

List all containers and display their namespaces.
列出所有容器并显示它们的命名空间。

$ podman ps --ns -a
CONTAINER ID    NAMES                                                                   PID     CGROUP       IPC          MNT          NET          PIDNS        USER         UTS
3557d882a82e3   k8s_container2_podsandbox1_redhat.test.crio_redhat-test-crio_1          29910   4026531835   4026532585   4026532593   4026532508   4026532595   4026531837   4026532594
09564cdae0bec   k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1          29851   4026531835   4026532585   4026532590   4026532508   4026532592   4026531837   4026532591
a31ebbee9cee7   k8s_podsandbox1-redis_podsandbox1_redhat.test.crio_redhat-test-crio_0   29717   4026531835   4026532585   4026532587   4026532508   4026532589   4026531837   4026532588

List all containers including size sorted by names.
按名称排序列出所有容器,包括大小。

$ podman ps -a --size --sort names
CONTAINER ID   IMAGE         COMMAND         CREATED       STATUS                    PORTS     NAMES
69ed779d8ef9f  redis:alpine  "redis-server"  25 hours ago  Created                   6379/tcp  k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1
02f65160e14ca  redis:alpine  "redis-server"  19 hours ago  Exited (-1) 19 hours ago  6379/tcp  k8s_podsandbox1-redis_podsandbox1_redhat.test.crio_redhat-test-crio_0

List all external containers created by tools other than Podman.
列出由除 Podman 之外的工具创建的所有外部容器。

$ podman ps --external -a
CONTAINER ID  IMAGE                             COMMAND  CREATED      STATUS  PORTS  NAMES
69ed779d8ef9f  redis:alpine  "redis-server"  25 hours ago  Created                   6379/tcp  k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1
38a8a78596f9  docker.io/library/busybox:latest  buildah  2 hours ago  storage        busybox-working-container
fd7b786b5c32  docker.io/library/alpine:latest   buildah  2 hours ago  storage        alpine-working-container
f78620804e00  scratch                           buildah  2 hours ago  storage        working-container

ps 

Print a list of containers
打印容器列表

SEE ALSO 参见 ¶

podman(1), buildah(1), crio(8)

HISTORY 历史 ¶

August 2017, Originally compiled by Urvashi Mohnani umohnani@redhat.com
2017 年 8 月,最初由 Urvashi Mohnani umohnani@redhat.com 编写