podman-build/docs/build/man/podman-rm.1
2025-10-11 12:30:35 +09:00

185 lines
4.8 KiB
Groff

'\" t
.nh
.TH podman-rm 1
.SH NAME
podman-rm \- Remove one or more containers
.SH SYNOPSIS
\fBpodman rm\fP [\fIoptions\fP] \fIcontainer\fP
.PP
\fBpodman container rm\fP [\fIoptions\fP] \fIcontainer\fP
.SH DESCRIPTION
\fBpodman rm\fP 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 \fB-f\fP option.
.SH OPTIONS
.SS \fB--all\fP, \fB-a\fP
Remove all containers. Can be used in conjunction with \fB-f\fP as well.
.SS \fB--cidfile\fP=\fIfile\fP
Read container ID from the specified \fIfile\fP and rm the container.
Can be specified multiple times.
.PP
Command does not fail when \fIfile\fP is missing and user specified --ignore.
.SS \fB--depend\fP
Remove selected container and recursively remove all containers that depend on it.
.SS \fB--filter\fP=\fIfilter\fP
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
\fBlabel\fR which is exclusive. Filters with different keys always work exclusive.
.PP
Valid filters are listed below:
.TS
allbox;
l l
l l .
\fB\fBFilter\fP\fP \fB\fBDescription\fP\fP
id T{
[ID] Container's ID (CID prefix match by default; accepts regex)
T}
name T{
[Name] Container's name (accepts regex)
T}
label T{
[Key] or [Key=Value] Label assigned to a container
T}
exited [Int] Container's exit code
status T{
[Status] Container's status: 'created', 'initialized', 'exited', 'paused', 'running', 'unknown'
T}
ancestor T{
[ImageName] Image or descendant used to create container
T}
before T{
[ID] or [Name] Containers created before this container
T}
since T{
[ID] or [Name] Containers created since this container
T}
volume T{
[VolumeName] or [MountpointDestination] Volume mounted in container
T}
health [Status] healthy or unhealthy
pod T{
[Pod] name or full or partial ID of pod
T}
network T{
[Network] name or full ID of network
T}
until T{
[DateTime] Containers created before the given duration or time.
T}
command T{
[Command] the command the container is executing, only argv[0] is taken
T}
.TE
.SS \fB--force\fP, \fB-f\fP
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.
.SS \fB--ignore\fP, \fB-i\fP
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.
.PP
Further ignore when the specified \fB--cidfile\fR does not exist as it may have
already been removed along with the container.
.SS \fB--latest\fP, \fB-l\fP
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)
.SS \fB--time\fP, \fB-t\fP=\fIseconds\fP
Seconds to wait before forcibly stopping the container.
Use -1 for infinite wait.
.PP
The --force option must be specified to use the --time option.
.SS \fB--volumes\fP, \fB-v\fP
Remove anonymous volumes associated with the container. This does not include named volumes
created with \fBpodman volume create\fP, or the \fB--volume\fP option of \fBpodman run\fP and \fBpodman create\fP\&.
.SH EXAMPLES
Remove container with a given name:
.EX
$ podman rm mywebserver
.EE
.PP
Remove container with a given name and all of the containers that depend on it:
.EX
$ podman rm --depend mywebserver
.EE
.PP
Remove multiple containers with given names or IDs:
.EX
$ podman rm mywebserver myflaskserver 860a4b23
.EE
.PP
Remove multiple containers with IDs read from files:
.EX
$ podman rm --cidfile ./cidfile-1 --cidfile /home/user/cidfile-2
.EE
.PP
Forcibly remove container with a given ID:
.EX
$ podman rm -f 860a4b23
.EE
.PP
Remove all containers regardless of the run state:
.EX
$ podman rm -f -a
.EE
.PP
Forcibly remove the last created container. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines):
.EX
$ podman rm -f --latest
.EE
.SH Exit Status
\fB0\fP All specified containers removed
.PP
\fB1\fP One of the specified containers did not exist, and no other failures
.PP
\fB2\fP One of the specified containers is paused or running
.PP
\fB125\fP The command fails for any other reason
.SH SEE ALSO
\fBpodman(1)\fP
.SH HISTORY
August 2017, Originally compiled by Ryan Cole rycole@redhat.com
\[la]mailto:rycole@redhat.com\[ra]