LinuxCommandLibrary

podman-rmi

Remove container images

TLDR

Remove one or more images given their names

$ podman rmi [image:tag image2:tag ...]
copy

Force remove an image
$ podman rmi --force [image]
copy

Remove an image without deleting untagged parents
$ podman rmi --no-prune [image]
copy

Display help
$ podman rmi
copy

SYNOPSIS

podman rmi [options] IMAGE [IMAGE...]

PARAMETERS

-a, --all
    Remove all images, not just specified ones. This option cannot be used with specific image names or IDs.

-f, --force
    Force removal of the image. This allows removal of images even if they are used by a running container, by stopping and removing the container first.

--no-prune
    Do not delete untagged parent images or untagged layers that are no longer referenced after removing a specific image.

DESCRIPTION

podman-rmi is used to remove one or more images from the local Podman storage. Images can be specified by their full or partial ID, name, or digest. When an image is removed, it frees up disk space consumed by that image's layers.

An image cannot be removed if it is currently in use by a running container unless the --force option is used. If an image is tagged multiple times, podman-rmi will only remove the specified tag. The underlying image data will only be deleted from storage if it becomes untagged and is not referenced by any other existing containers or images.

This command is essential for managing local image storage, cleaning up old or unused images, and recovering disk space, especially in development environments where images are frequently built and discarded.

CAVEATS

Running Containers: An image cannot be removed if it is actively being used by a running container without the --force flag. Attempting to do so will result in an error.

Shared Layers and Disk Space: Image removal only frees up space if all references to its layers are gone. If layers are shared by other images, those layers will not be deleted until all referencing images are removed.

Tagged Images: If an image has multiple tags, podman-rmi only removes the specific tag provided. The image itself and its data are only removed when its last tag is gone and no containers depend on it.

IMAGE IDENTIFIERS

Images can be identified for removal using their short or full image ID, their repository name (e.g., fedora:latest or myregistry.com/myimage), or a specific digest (e.g., myimage@sha256:...). When using a name, only the specified tag is removed. If the image has multiple tags and the specified tag is removed, the image remains until its last tag is removed and no containers are dependent on it.

DANGLING IMAGES

Images that have no associated tags but still consume disk space are often referred to as 'dangling' images. While podman-rmi can remove specific untagged images by their ID, the podman image prune command is typically more efficient for clearing all dangling and unused images that are not referenced by any containers or other images.

HISTORY

podman-rmi is a core command within the Podman project, an open-source, daemonless container engine for developing, managing, and running OCI Containers on Linux. It was developed as a direct analog to the docker rmi command, providing a familiar interface for users migrating from Docker to Podman, while adhering to Podman's unique daemonless architecture. Its functionality aligns with standard container image management practices.

SEE ALSO

podman(1), podman-images(1), podman-image-prune(1), podman-build(1), podman-pull(1), podman-container-rm(1)

Copied to clipboard