Follow the steps of this tutorial to install the Podman container tool on Ubuntu 20.04 LTS Focal Fossa 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 20.04 LTS
The other Linux systems that are based on Ubuntu 20.04 LTS such as POP_OS can also use the steps and commands given below to use this container tool.
1. Update Ubuntu 20.04
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 && sudo apt upgrade
Also, install CURL:
sudo apt install curl
2. Add Podman Repository
In Ubuntu 20.10 or newer versions, the packages to install Podman are included to download in the standard repository of the system. However, the same is not for Ubuntu 20.04, therefore, we manually have to add the repository of Podman. On your command terminal runs the following commands.
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
Add GPG Key:
curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/Release.key" | sudo apt-key add -
Again run the system update command:
sudo apt update
3. Install Podman on Ubuntu 20.04
Finally, after adding the repository we can install the Podman on Ubuntu 20.04 LTS Linux using the system’s default APT package manager like any other software.
sudo apt install podman
4. Check the version
Once the installation is completed to check the version of the installed Podman, we can use:
5. 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 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:
6. Search and pull images on Ubuntu 20.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:
8. 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
9. 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