NAME 名称

podman-rm - Remove one or more containers
podman-rm - 删除一个或多个容器

SYNOPSIS 概要

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

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

DESCRIPTION 描述

podman rm removes one or more containers from the host. The container name or ID can be used. This does not remove images. Running or unusable containers are not removed without the -f option.
podman rm 从主机中删除一个或多个容器。可以使用容器名称或 ID。这不会删除镜像。在没有 -f 选项的情况下,不会删除正在运行或无法使用的容器。

OPTIONS 选项

--all, -a

Remove all containers. Can be used in conjunction with -f as well.
删除所有容器。也可以与 -f 一起使用。

--cidfile=file

Read container ID from the specified file and rm the container. Can be specified multiple times.
从指定文件中读取容器 ID 并删除容器。可以多次指定。

Command does not fail when file is missing and user specified --ignore.
当文件丢失并且用户指定了 --ignore 时,命令不会失败。

--depend

Remove selected container and recursively remove all containers that depend on it.
删除选定的容器,并递归删除所有依赖于它的容器。

--filter=filter

Filter what containers remove. 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
[键] 或 [键=值] 分配给容器的标签

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
[镜像名称] 用于创建容器的镜像或后代

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] Containers created before the given duration or time.
[日期时间] 在给定持续时间或时间之前创建的容器。

--force, -f

Force the removal of running and paused containers. Forcing a container removal also removes containers from container storage even if the container is not known to Podman. For example, containers that are created by different container engines like Buildah. In addition, forcing can be used to remove unusable containers, e.g. containers whose OCI runtime has become unavailable.
强制删除正在运行和暂停的容器。强制删除容器还会从容器存储中删除容器,即使 Podman 不知道该容器也是如此。例如,由不同容器引擎(如 Buildah)创建的容器。此外,强制删除可用于删除无法使用的容器,例如,OCI 运行时不可用的容器。

--ignore, -i

Ignore errors when specified containers are not in the container store. A user might have decided to manually remove a container which leads to a failure during the ExecStop directive of a systemd service referencing that container.
当指定的容器不在容器存储中时忽略错误。用户可能已经决定手动删除一个容器,这会导致在引用该容器的 systemd 服务的 ExecStop 指令期间失败。

Further ignore when the specified --cidfile does not exist as it may have already been removed along with the container.
进一步忽略当指定的 --cidfile 不存在时,因为它可能已经随着容器一起被移除。

--latest, -l

Instead of providing the container name or ID, use the last created container. Note: the last started container can be from other users of Podman on the host machine. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
不要提供容器名称或 ID,而是使用最后创建的容器。注意:最后启动的容器可能来自主机上其他 Podman 用户。(此选项在远程 Podman 客户端中不可用,包括 Mac 和 Windows(不包括 WSL2)主机)

--time, -t=seconds --time, -t=秒数

Seconds to wait before forcibly stopping the container. Use -1 for infinite wait.
强制停止容器之前等待的秒数。使用 -1 表示无限等待。

The --force option must be specified to use the --time option.
必须指定 --force 选项才能使用 --time 选项。

--volumes, -v

Remove anonymous volumes associated with the container. This does not include named volumes created with podman volume create, or the --volume option of podman run and podman create.
删除与容器关联的匿名卷。这不包括使用 podman volume create 创建的命名卷,也不包括 podman run 和 podman create 的 --volume 选项。

EXAMPLE 例子 ¶

Remove container with a given name:
使用给定名称删除容器:

$ podman rm mywebserver

Remove container with a given name and all of the containers that depend on it:
使用给定名称删除容器以及所有依赖于它的容器:

$ podman rm --depend mywebserver

Remove multiple containers with given names or IDs:
使用给定名称或 ID 删除多个容器:

$ podman rm mywebserver myflaskserver 860a4b23

Remove multiple containers with IDs read from files:
使用从文件中读取的 ID 删除多个容器:

$ podman rm --cidfile ./cidfile-1 --cidfile /home/user/cidfile-2

Forcibly remove container with a given ID:
强制删除具有给定 ID 的容器:

$ podman rm -f 860a4b23

Remove all containers regardless of the run state:
无论运行状态如何,删除所有容器:

$ podman rm -f -a

Forcibly remove the last created container. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines):
强制删除最后创建的容器。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不包括 WSL2)机器):

$ podman rm -f --latest

Exit Status 退出状态 ¶

0 All specified containers removed
已删除所有指定的容器

1 One of the specified containers did not exist, and no other failures
1 指定的容器之一不存在,且没有其他故障

2 One of the specified containers is paused or running
2 指定的容器之一已暂停或正在运行

125 The command fails for any other reason
125 由于其他原因命令失败

SEE ALSO 参见 ¶

podman(1)

HISTORY 历史 ¶

August 2017, Originally compiled by Ryan Cole rycole@redhat.com
2017 年 8 月,最初由 Ryan Cole rycole@redhat.com 编译