billysoftacademy.com

Learn how to Install and Use Podman on Ubuntu 20.04 and 22.04 LTS

Introduction

Podman is a software that enables the creation, administration, and operation of containers and images. It is created by Red Hat and intended to serve as a seamless replacement for Docker. Podman and Docker have a lot in common, but the key distinctiveness between the two is that Docker is reliant on the Docker Engine daemon, while Podman can execute containers without the need for a daemon. Additionally, Podman can manage various image formats and supports loading images in many ways. In this guide, we will illustrate how to install and utilize Podman on an Ubuntu server. The process is applicable to both Ubuntu 20.04 and Ubuntu 22.04.

Requirements

In order to complete this guide successfully, the following is a list of items that are required:
1) A desktop or laptop with 4GB RAM, a dual core processor and atleast 50GB of free disk space
2) Linux Ubuntu Server 20.04 or 22.04 LTS
3) An SSH client such as Putty or the Terminal app on MacOS
4) For cloud deployment a fully qualified domain name and a public static IP address may be needed
5) A stable internet connection

Overview

In this part, we will explain how to search and retrieve images, and run a container using the Podman command. To find Debian-10 images, you can use the command below: podman search debian-10 You should see a list of Debian 10 images in the result. To download the Nginx image, you can use the command below: podman pull nginx You should see the output showing that the image has been downloaded. To list all downloaded images, you can use the command below: podman images You should see a list of the images you have downloaded. To create a new container from the Nginx image, you can use the command below: podman run -dit nginx You can check the Nginx container with the following command: podman ps To create a new image from the running Nginx container, you can use the command below: podman commit –author “Author Name Hitesh” container-id docker.io/library/new-nginx You can check the newly created image with the following command: podman images To stop the running container, you can use the command below: podman stop container-id To remove the running container, you can use the command below: podman remove container-id To stop and start the latest container, you can use the commands below: podman stop –latest podman start –latest To remove the latest container, you can use the command below: podman rm –latest

Step 1: Download and install Podman

Initially, it is required to install some certain dependencies to successfully install Podman. You can download and install all the dependencies with the below-stated command:
apt-get install curl wget gnupg2 -y
After installing the dependencies, you need to set up the Podman repository by sourcing your Ubuntu release with the following command:
source /etc/os-release
sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
Now, it’s time to download and add the GPG key with a command. Use the below command to complete this step:
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add -
After that, update the repository and install Podman with the following command:
apt-get update -qq -y
apt-get -qq --yes install podman
Once Podman is installed, you can verify the Podman version with the following command:
podman --version
Upon executing the above command, you should get the following output:
podman version 3.1.2
In addition to this, you can also check more information about Podman with the following command:
podman info

Step 2: Add the OCI Registry

Now that Podman is installed the next thing you need to do is check for a list of registries in the registry configuration file located at /etc/containers/registries.conf. For customization purposes, you can easily add and edit different registries in the configuration file. All you have to do is open the file with nano and add the following lines at the end of it:
[registries.search]
registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
Once you’re done with the editing, make sure to save the file and close it.

Step 3: Learning how to use Podman

In this part, we will explain how to search and retrieve images, and run a container using the Podman command. To find Debian-10 images, you can use the command below:

podman search debian-10

You should see a list of Debian 10 images in the result.

To download the Nginx image, you can use the command below:

podman pull nginx

You should see the output showing that the image has been downloaded.

To list all downloaded images, you can use the command below:
podman images

You should see a list of the images you have downloaded.

To create a new container from the Nginx image, you can use the command below:

podman run -dit nginx

You can check the Nginx container with the following command:

podman ps

To create a new image from the running Nginx container, you can use the command below:

podman commit --author "Author Name BillysoftAcademy" container-id docker.io/library/new-nginx

You can check the newly created image with the following command:

podman images

To stop the running container, you can use the command below:

podman stop container-id

To remove the running container, you can use the command below:

podman remove container-id

To stop and start the latest container, you can use the commands below:

podman stop --latest
podman start --latest

To remove the latest container, you can use the command below:

podman rm --latest

Conclusion

In this tutorial, you learnt how to download, install and use Podman on Linux Ubuntu. We hope that this tutorial has been informative and we would like to thank you for reading it. Please visit the home page for more helpful guides and tutorials.
Scroll to Top