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) |
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 |
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] 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¶ 参见 ¶
HISTORY¶ 历史 ¶
August 2017, Originally compiled by Ryan Cole rycole@redhat.com
2017 年 8 月,最初由 Ryan Cole rycole@redhat.com 编译