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) |
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 |
since |
[ID] or [Name] Containers created since this container |
volume |
[VolumeName] or [MountpointDestination] Volume mounted in container |
health |
[Status] healthy or unhealthy |
pod |
[Pod] name or full or partial ID of pod |
network |
[Network] name or full ID of network |
until |
[DateTime] container created before the given duration or time. |
--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 |
.ExitedAt |
Time (epoch seconds) that container exited |
.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 |
.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 |
.Pod |
Pod the container is associated with (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 |
.State |
Human-friendly description of ctr state |
.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¶ 参见 ¶
HISTORY¶ 历史 ¶
August 2017, Originally compiled by Urvashi Mohnani umohnani@redhat.com
2017 年 8 月,最初由 Urvashi Mohnani umohnani@redhat.com 编写