How to use the command `podman images` (with examples)

How to use the command `podman images` (with examples)

Podman is a container engine that allows you to manage containers and container images. The podman images command is used to list and manage Podman images.

Use case 1: List all Podman images

Code:

podman images

Motivation: This use case is useful when you want to see a list of all the Podman images available on your system. It provides an overview of the images that you can use to create containers.

Explanation: The podman images command without any options lists all the Podman images available on the system. This includes the repository, tag, image ID, and creation date/time.

Example output:

REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
quay.io/podman/stable       latest    8a696b584fa6   2 weeks ago      68.6 MB
docker.io/library/alpine    latest    053cde6e8953   4 weeks ago      5.6 MB

Use case 2: List all Podman images including intermediates

Code:

podman images --all

Motivation: This use case is helpful when you need to see all Podman images, including intermediate images. Intermediate images are the layers produced during the build process that are not tagged with a repository and tag.

Explanation: The --all option is used to include all images, including the intermediate images in the output. By default, Podman only shows the topmost images for each repository and tag.

Example output:

REPOSITORY                  TAG         IMAGE ID       CREATED          SIZE
quay.io/podman/stable       latest      8a696b584fa6   2 weeks ago      68.6 MB
<none>                      <none>      36150b470cc1   2 weeks ago      63.6 MB
<none>                      <none>      4e76449cac7c   2 weeks ago      68.6 MB
docker.io/library/alpine    latest      053cde6e8953   4 weeks ago      5.6 MB

Use case 3: List the output in quiet mode (only numeric IDs)

Code:

podman images --quiet

Motivation: This use case is useful when you only need the numeric IDs of the Podman images for scripting purposes or filtering output.

Explanation: The --quiet option is used for quiet mode, which only displays the numeric IDs of the images. The repository, tag, and other information are not included in the output.

Example output:

8a696b584fa6
36150b470cc1
4e76449cac7c
053cde6e8953

Use case 4: List all Podman images not used by any container

Code:

podman images --filter dangling=true

Motivation: This use case helps in identifying the Podman images that are no longer associated with any container. These “dangling” images can use up valuable disk space and may need to be cleaned up.

Explanation: The --filter dangling=true option filters the list of images to only show the ones that are not being used by any running or stopped containers.

Example output:

REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
docker.io/library/alpine    latest    053cde6e8953   4 weeks ago    5.6 MB

Use case 5: List images that contain a substring in their name

Code:

podman images "*image|image*"

Motivation: This use case is useful when you want to search for specific images that contain a particular substring in their repository or tag.

Explanation: The argument passed to podman images is a shell glob pattern that filters the images based on their repository or tag names. The asterisk (*) is a wildcard character that allows matching any number of characters, and the vertical bar (|) is a logical OR operator. In this example, the pattern matches images that have either “image” or “image” anywhere in their repository or tag name.

Example output:

REPOSITORY                  TAG      IMAGE ID       CREATED          SIZE
my-image                    latest   c471ae235ff3   2 weeks ago      27.4 MB
other-image                 latest   f34a84cb586b   3 weeks ago      84.6 MB
another-image               latest   9dbdca6084f1   4 weeks ago      33.3 MB

Conclusion:

The podman images command is a versatile tool for managing Podman images. It provides various options to list images, including intermediate images, filter them based on criteria like dangling status, and search images using a substring pattern. Understanding these use cases can help you effectively manage your Podman image repository.

Related Posts

How to use the command 'birdc' (with examples)

How to use the command 'birdc' (with examples)

The ‘birdc’ command is a command line tool used for remote control of the Bird routing daemon.

Read More
How to use the command 'import' (with examples)

How to use the command 'import' (with examples)

The ‘import’ command is a part of ImageMagick and allows users to capture all or a portion of an X server screen and save it as an image file.

Read More
How to use the command "yard" (with examples)

How to use the command "yard" (with examples)

Description: The yard command is a documentation tool for Ruby. It allows you to generate documentation for your Ruby codebase.

Read More