Follow the steps of this tutorial to install the Podman container tool on Ubuntu 22.04 LTS Jammy JellyFish Linux for creating virtual containers.
Podman is a container tool for virtualizing applications. It was originally developed by Red Hat and originated in the Cri-O project, which develops a lightweight container runtime environment for Kubernetes as an alternative to the Docker runtime environment.
It is compatible with Docker on the command line however doesn’t rely on the Docker daemon. Hence, we can use its Container Engine to provide containers without root access. Buildah is the Image builder used by Podman.
Podman can create pods that are aligned with the Pods of the Kubernetes container orchestration. It is a part of libpod. libpod is hosted on GitHub and is licensed under apache license 2.0.
This platform is also available for Fedora, Ubuntu, CentOS, Rocky, and other Linux.
Steps to install Podman on Ubuntu 22.04 LTS
The other Linux systems that are based on Ubuntu 22.04 LTS such as POP_OS can also use the steps and commands given below to use this container tool.
1. Use Apt Update
The first task to perform on your system is to run the update command. This will not only install the latest available security updates but also rebuild the repository cache.
sudo apt update
2. Install Podman on Ubuntu 22.04
In Ubuntu 20.10 or newer versions, the packages to install Podman are included to download in the standard repository of the system. Hence, even on Ubuntu 22.04, we can install the Podman without adding any third-party repository. Simply follow the given APT command:
sudo apt install podman
3. Check the version
Once the installation is completed to check the version of the installed Podman, we can use:
4. Set Podman registries conf
By default there will be no repository to fetch and install container Images by Podman, hence we need to do that manually so that we can use the popular repositories such as Docker.io, Redhat, and Fedora.
Edit Registry configuration file
sudo nano /etc/containers/registries.conf
Scroll to the end of the file and paste the given line:
[registries.search] registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
After that save the file by pressing Ctrl+O, hit the Enter key, and then exit using Ctrl+X.
To get full information about Podman, you can use:
5. Search and pull images on Ubuntu 22.04
Just like Docker, we can use the Podman command line to search Images but from different repositories, added in the previous step.
For example, if we want to install a Ubuntu container using Podman, then you can search what are the images available through the different repositories.
podman search ubuntu
Now, to download and pull images, we can use:
podman pull ubuntu
As we have added multiple repositories in Podman to pull container images, hence it will ask you to select the repository you want to use to pull the Image of the app you want:
After selecting the repository, the Podman will automatically download it.
7. List all Images
If you have downloaded multiple images and now want to see what are the available images on your system, we can list all of them using the given command:
6. Create Container
Once you have the image of the application that you want, we can create a container using it. Here we have downloaded two images one is of MariaDB and the other of Ubuntu, hence we will show how to use it to create a container using Ubuntu Image.
podman run -dit --name h2smediaa ubuntu
–name is a parameter to give the container whatever friendly name we want to assign, here we have used h2smediaa whereas Ubuntu is the name of the Image we have downloaded and want to use.
Get running container command-line access:
podman attach container-name
podman attach h2smediaa
7. Stop or Start a Container
If you want to start or stop any container, then the command will be:
podman stop container-id or name
podman stop h2smediaa
podman start container-id or name
podman stop h2smediaa