Chapter 4. Working with container images
The Podman tool is designed to work with container images. You can use this tool to pull the image, inspect, tag, save, load, redistribute, and define the image signature.
4.1. Pulling images from registries
				Use the podman pull command to get the image to your local system.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- Log in to the registry.redhat.io registry: - podman login registry.redhat.io - $ podman login registry.redhat.io Username: <username> Password: <password> Login Succeeded!- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Pull the registry.redhat.io/ubi10/ubi container image: - podman pull registry.redhat.io/ubi10/ubi - $ podman pull registry.redhat.io/ubi10/ubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- List all images pulled to your local system: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi10/ubi latest 3269c37eae33 7 weeks ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.2. Pulling container images using short-name aliases
				You can use secure short names to get the image to your local system. The following procedure describes how to pull a fedora or nginx container image.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- Pull the container image: - Pull the - fedoraimage:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Alias is found and the - registry.fedoraproject.org/fedoraimage is securely pulled. The- unqualified-search-registrieslist is not used to resolve- fedoraimage name.
- Pull the - nginximage:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - If no matching alias is found, you are prompted to choose one of the - unqualified-search-registrieslist. If the selected image is pulled successfully, a new short-name alias is recorded locally, otherwise an error occurs.
 
Verification
- List all images pulled to your local system: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.fedoraproject.org/fedora latest 28317703decd 12 days ago 184 MB docker.io/library/nginx latest 08b152afcfae 13 days ago 137 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.3. Listing images
				Use the podman images command to list images in your local storage.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
- A pulled image is available on the local system.
Procedure
- List all images in the local storage: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.access.redhat.com/ubi10/ubi latest 3269c37eae33 6 weeks ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.4. Inspecting local images
				After you pull an image to your local system and run it, you can use the podman inspect command to investigate the image. For example, use it to understand what the image does and check what software is inside the image. The podman inspect command displays information about containers and images identified by name or ID.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
- A pulled image is available on the local system.
Procedure
- Inspect the - registry.redhat.io/ubi10/ubiimage:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - The - "Cmd"key specifies a default command to run within a container. You can override this command by specifying a command as an argument to the- podman runcommand. This ubi10/ubi container will execute the bash shell if no other argument is given when you start it with- podman run. If an- "Entrypoint"key was set, its value would be used instead of the- "Cmd"value, and the value of- "Cmd"is used as an argument to the Entrypoint command.
4.5. Inspecting remote images
				Use the skopeo inspect command to display information about an image from a remote container registry before you pull the image to your system.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- Inspect the - registry.redhat.io/ubi10/ubi-initimage:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.6. Copying container images
				You can use the skopeo copy command to copy a container image from one registry to another. For example, you can populate an internal repository with images from external registries, or sync image registries in two different locations.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- Copy the - skopeocontainer image from- docker://quay.ioto- docker://registry.example.com:- skopeo copy docker://quay.io/skopeo/stable:latest docker://registry.example.com/skopeo:latest - $ skopeo copy docker://quay.io/skopeo/stable:latest docker://registry.example.com/skopeo:latest- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.7. Copying image layers to a local directory
				You can use the skopeo copy command to copy the layers of a container image to a local directory.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- Create the - /var/lib/images/nginxdirectory:- mkdir -p /var/lib/images/nginx - $ mkdir -p /var/lib/images/nginx- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Copy the layers of the - docker://docker.io/nginx:latest imageto the newly created directory:- skopeo copy docker://docker.io/nginx:latest dir:/var/lib/images/nginx - $ skopeo copy docker://docker.io/nginx:latest dir:/var/lib/images/nginx- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Display the content of the - /var/lib/images/nginxdirectory:- ls /var/lib/images/nginx - $ ls /var/lib/images/nginx 08b11a3d692c1a2e15ae840f2c15c18308dcb079aa5320e15d46b62015c0f6f3 ... 4fcb23e29ba19bf305d0d4b35412625fea51e82292ec7312f9be724cb6e31ffd manifest.json version- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.8. Tagging images
				Use the podman tag command to add an additional name to a local image. This additional name can consist of several parts: <registryhost>/<username>/<name>:<tag>.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
- A pulled image is available on the local system.
Procedure
- List all images: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi10/ubi latest 3269c37eae33 7 weeks ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign the - myubiname to the- registry.redhat.io/ubi10/ubiimage using one of the following options:- The image name: - podman tag registry.redhat.io/ubi10/ubi myubi - $ podman tag registry.redhat.io/ubi10/ubi myubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- The image ID: - podman tag 3269c37eae33 myubi - $ podman tag 3269c37eae33 myubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Both commands give you the same result. 
 
- List all images: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi10/ubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi latest 3269c37eae33 2 months ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Notice that the default tag is - latestfor both images. You can see all the image names are assigned to the single image ID 3269c37eae33.
- Add the - 10tag to the- registry.redhat.io/ubi10/ubiimage using either:- The image name: - podman tag registry.redhat.io/ubi10/ubi myubi:10 - $ podman tag registry.redhat.io/ubi10/ubi myubi:10- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- The image ID: - podman tag 3269c37eae33 myubi:10 - $ podman tag 3269c37eae33 myubi:10- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Both commands give you the same result. 
 
Verification
- List all images: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi10/ubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi 10 3269c37eae33 2 months ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Notice that the default tag is - latestfor both images. You can see all the image names are assigned to the single image ID 3269c37eae33.
				After tagging the registry.redhat.io/ubi10/ubi image, you have three options to run the container:
			
- 
						by ID (3269c37eae33)
- 
						by name (localhost/myubi:latest)
- 
						by name (localhost/myubi:10)
4.9. Building multi-architecture images
Prerequisites
- The - container-toolsmeta-package is installed.- 
								Create Containerfilesfor each architecture you want to support.
- Build images for each architecture. For example: - podman build --platform linux/arm64,linux/amd64 --manifest <registry>/<image> . - $ podman build --platform linux/arm64,linux/amd64 --manifest <registry>/<image> .- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 
										The --platform linux/arm64,linux/amd64option specifies the target platforms for which the container image is being built.
- 
										The --manifest <registry>/<image>option creates a manifest list with the specified name, that is<registry>/<image>, and adds the newly-built images to them. A manifest list is a collection of image manifests, each one targeting a different architecture.
 
- 
										The 
- Push the manifest list to the registry: - podman manifest push <registry>/<image> - $ podman manifest push <registry>/<image>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - This manifest list acts as a single entry point for pulling the multi-architecture container. 
 
- 
								Create 
As a result, you can pull the appropriate container image for your platform, based on a single manifest list.
				You can also remove items from the manifest list by using the podman manifest remove <manifest_list> <digest_ID> command, where <digest_ID> is the SHA-256 checksum of the container image. For example: podman manifest remove <registry>/<image> sha256:cb8a924afdf….
			
Verification
- Display the manifest list: - podman manifest inspect <registry>/<image> - $ podman manifest inspect <registry>/<image>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.10. Saving and loading images
				Use the podman save command to save an image to a container archive. You can restore it later to another container environment or send it to someone else. You can use --format option to specify the archive format. The supported formats are:
			
- 
						docker-archive
- 
						oci-archive
- 
						oci-dir(directory with oci manifest type)
- 
						docker-archive(directory with v2s2 manifest type)
				The default format is the docker-archive format.
			
				Use the podman load command to load an image from the container image archive into the container storage.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
- A pulled image is available on the local system.
Procedure
- Save the - registry.redhat.io/rhel10/support-toolsimage as a tarball:- In the default - docker-archiveformat:- podman save -o mysupport-tools.tar registry.redhat.io/rhel10/support-tools:latest - $ podman save -o mysupport-tools.tar registry.redhat.io/rhel10/support-tools:latest- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- In the - oci-archiveformat, using the- --formatoption:- podman save -o mysupport-tools-oci.tar --format=oci-archive registry.redhat.io/rhel10/support-tools - $ podman save -o mysupport-tools-oci.tar --format=oci-archive registry.redhat.io/rhel10/support-tools- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - The - mysupport-tools.tarand- mysupport-tools-oci.tararchives are stored in your current directory. The next steps are performed with the- mysupport-tools.tartarball.
 
- Check the file type of - mysupport-tools.tar:- file mysupport-tools.tar - $ file mysupport-tools.tar mysupport-tools.tar: POSIX tar archive- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To load the - registry.redhat.io/rhel10/support-tools:latestimage from the- mysupport-tools.tar:- podman load -i mysupport-tools.tar - $ podman load -i mysupport-tools.tar ... Loaded image(s): registry.redhat.io/rhel10/support-tools:latest- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.11. Redistributing UBI images
				Use podman push command to push a UBI image to your own, or a third party, registry and share it with others. You can upgrade or add to that image from UBI dnf repositories as you like.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
- A pulled image is available on the local system.
Procedure
- Optional: Add an additional name to the - ubiimage:- podman tag registry.redhat.io/ubi10/ubi registry.example.com:5000/ubi10/ubi - # podman tag registry.redhat.io/ubi10/ubi registry.example.com:5000/ubi10/ubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Push the - registry.example.com:5000/ubi10/ubiimage from your local storage to a registry:- podman push registry.example.com:5000/ubi10/ubi - # podman push registry.example.com:5000/ubi10/ubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
While there are few restrictions on how you use these images, there are some restrictions about how you can refer to them. For example, you cannot call those images Red Hat certified or Red Hat supported unless you certify it through the Red Hat Partner Connect Program, either with Red Hat Container Certification or Red Hat OpenShift Operator Certification.
4.12. Removing images
				Use the podman rmi command to remove locally stored container images. You can remove an image by its ID or name.
			
Prerequisites
- 
						The container-toolsmeta-package is installed.
Procedure
- List all images on your local system: - podman images - $ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/rhel10/support-tools latest 4b32d14201de 7 weeks ago 228 MB registry.redhat.io/ubi10/ubi latest 3269c37eae33 7 weeks ago 208 MB localhost/myubi X.Y 3269c37eae33 7 weeks ago 208 MB- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- List all containers: - podman ps -a - $ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7ccd6001166e registry.redhat.io/rhel10/support-tools:latest usr/bin/bash 6 seconds ago Up 5 seconds ago my-support-tools- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - To remove the - registry.redhat.io/rhel10/support-toolsimage, you have to stop all containers running from this image by using the- podman stopcommand. You can stop a container by its ID or name.
- Stop the - my-support-toolscontainer:- podman stop my-support-tools - $ podman stop my-support-tools 7ccd6001166e9720c47fbeb077e0afd0bb635e74a1b0ede3fd34d09eaf5a52e9- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Remove the - registry.redhat.io/rhel10/support-toolsimage:- podman rmi registry.redhat.io/rhel10/support-tools - $ podman rmi registry.redhat.io/rhel10/support-tools- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - To remove multiple images: - podman rmi registry.redhat.io/rhel10/support-tools registry.redhat.io/ubi10/ubi - $ podman rmi registry.redhat.io/rhel10/support-tools registry.redhat.io/ubi10/ubi- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To remove all images from your system: - podman rmi -a - $ podman rmi -a- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To remove images that have multiple names (tags) associated with them, add the - -foption to remove them:- podman rmi -f 1de7d7b3f531 - $ podman rmi -f 1de7d7b3f531 1de7d7b3f531...- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
Verification
- 
						List all images by using the podman imagescommand to verify that container images were removed.