Learn how to Install and Use Podman on Ubuntu 20.04 and 22.04 LTS
Introduction
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
Step 1: Download and install Podman
apt-get install curl wget gnupg2 -yAfter 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 podmanOnce Podman is installed, you can verify the Podman version with the following command:
podman --versionUpon executing the above command, you should get the following output:
podman version 3.1.2In addition to this, you can also check more information about Podman with the following command:
podman info
Step 2: Add the OCI Registry
[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