After installing Podman you have to know and understand some of the terminology. Understanding the basic jargon of containerization will help you start with this lesson, and it will be beneficial later on too. You will learn about the image registries, images and containers in this lesson. You will take a look at how to pull, run and manage them.
Podman registries are repositories where container images are stored, allowing users to search, pull, and manage these images. Users can interact with registries to access a wide range of container images for their applications.
Podman images are snapshots of containers that include the application and its dependencies, serving as the building blocks for containers. These images can be created, pulled from registries, inspected, and run as containers.
Containers in Podman are instances of images that are executed and run in isolation, encapsulating the application and its environment. Users can create, manage, and interact with containers to deploy and run applications efficiently.
Registries
Podman registries are repositories where container images are stored, allowing users to access and manage these images for their applications. Registries are a crucial component of the Podman ecosystem, as they serve as the source for container images that can be pulled and run as containers.
The primary function of Podman registries is to store and distribute container images. Users can interact with these registries to search for, pull, and push container images as needed. Registries can be public, such as Docker Hub, or private, managed by an organization for internal use. Podman supports interacting with a variety of registries, including the pre-configured options like Docker Hub, Red Hat Quay, GitHub, and Google Container Registry, as well as custom registries that users can set up themselves.
To use a registry with Podman, users need to configure the necessary credentials, such as username and password or OAuth secret, in the Podman configuration file located at /etc/containers/registries.conf. This file also allows users to specify optional features, such as allowing insecure certificates for registries with self-signed certificates.
Docker Hub is a well known image registry of the field. To search images on Docker Hub you have to use the following search text:
podman search docker.io/debian
Most of the official images can be found in the library namespace.
docker.io/library/debian
Other custom images will have their own namespace like the example below.
docker.io/dockette/debian
Additionally you can use filters to narrow down the list of images while searching in a registry.
podman image search --filter=is-official docker.io/debian
After finding the images you want to use, you will want to download (pull) them locally to your Podman machine.
Pulling an image
Pulling a Podman image refers to the process of copying an image from a registry onto the local machine. When you execute the podman pull command, Podman retrieves the specified image from a registry, such as Docker Hub, and downloads it to the local system. This action allows users to access container images stored in registries and use them to create and run containers locally. Additionally, pulling an image can involve specifying options like image tags, digests, or using different transports to fetch the image. Overall, pulling a Podman image is a fundamental step in working with containerized applications, enabling users to acquire the necessary images for their container deployments.
To pull a basic test image from the Docker Hub use the following command:
podman pull docker.io/library/hello-world
In most cases you will pull different versions of an image. You can do it with using the image tags.
In Podman, tags are used to provide additional names or versions for container images. Tags allow users to differentiate between multiple versions of the same base image, such as “latest”, “v1.0”, or “10.11.12”.
When pulling or referencing a Podman image, the tag can be specified after the image name, separated by a colon, to access the desired version of the image:
podman pull docker.io/library/debian:latest
To list the images pulled locally you have to use the following command:
podman image ls
Every podman subcommand has a --help option that will give you detailed information about using the actual command.
podman image ls --noheading --quiet
As an example, the above command and options will display all local images’ image IDs without the header.
Now you have images locally on your system, let’s take a look at how can you run them as containers!
Running a container
A Podman container is a standardized, self-contained software package that encapsulates an application and its dependencies, enabling it to run consistently across different environments without the need for customization.
A container is a running (or stopped/exited) instance of an image.
To run a container you have to use the run subcommand, as in the example below:
podman run hello-world:latest
The above example will create a container instance of the hello-world image. This container will output some text on the screen while running and stop after it.
To run a container interactively and get a terminal in it you can use the -i and -t flags. Using the --rm option will remove the container after exiting from it.
podman run --rm -it debian:latest
root@a6ac367fbc82:/#
The above command example will start a Debian container using the latest tag and drop you in the container’s console. When you hit Ctrl+q or type exit then the container will be removed from the system automatically because of the --rm option.
Let’s take a look at how can you remove the stopped/exited containers from the system!
Removing a stopped or exited container
Exited or stopped Podman containers are instances of containers that have completed their execution or have been manually halted by the user. When a container is in an exited or stopped state, it means that the processes within the container have finished running, and the container is no longer actively processing data or performing tasks. These containers do not have an active process in the process tree, as they are not running any commands or applications.
If you want to remove an exited or stopped container from the system you have to be able to list the containers. It happens with the container subcommand’s ps option. This command without any other options will list only the running containers.
podman container ps
To see the exited/stopped containers add the --all option to the command:
podman container ps --all
Now you can see all the exited and stopped containers on your local system. You can remove them one by one using their container ID and the rm option of the container subcommand:
podman container rm 6afaab9c8f30
With these commands you can keep the order on your local system without a large number of unused containers on it.
If you don’t need the image anymore or you want to use another version or tag of an image you obviously can remove images as well from your local system.
Removing a Podman image from the disk
Images can take up a lot of space on your Podman host machine. Sometimes multiple versions of the same image can remain unused on the file system using the precious free space and making the system unstable. That’s why you have to manage your images properly and remove the unnecessary versions.
To remove a Podman image or multiple images at once you can use the rmi subcommand and the image IDs of the images you want to erase from the system:
podman rmi a6916e41aa87
This way you will keep the order on your system.
If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES
Now we have an IRC channel as well: irc.libera.chat / #tomsitcafe