Podman is a tool used for developing, managing, and running containers and images. It is developed by Red Hat and designed to be a drop-in Docker replacement. Podman is very similar to Docker. The main difference is that Docker needs the Docker Engine daemon while Podman doesn’t require a daemon to run containers. It supports multiple image formats and several ways to load images.
In this post, we will show you how to install and use Podman on an Ubuntu server. This procedure is compatible with Ubuntu 20.04 and Ubuntu 22.04.
Step 1 – Install Podman
First, you will need to install some dependencies required to install Podman. You can install them with the following command:
apt-get install curl wget gnupg2 -y
Next, source your Ubuntu release and add the Podman repository 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"
Next, download and add the GPG key with the following command:
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add -
Next, update the repository and install Podman with the following command:
apt-get update -qq -y apt-get -qq --yes install podman
After installing Podman, verify the Podman version with the following command:
podman --version
You should get the following output:
podman version 3.1.2
You can also check more information with the following command:
podman info
You should see the following output:
host: arch: amd64 buildahVersion: 1.20.1 cgroupManager: systemd cgroupVersion: v1 conmon: package: 'conmon: /usr/libexec/podman/conmon' path: /usr/libexec/podman/conmon version: 'conmon version 2.0.27, commit: ' cpus: 2 distribution: distribution: ubuntu version: "20.04" eventLogger: journald hostname: ubuntu2004 idMappings: gidmap: null uidmap: null kernel: 5.4.0-29-generic
Step 2 – Add OCI Registry
When you pull an image using the Podman command, it will look for a list of registries from the registry configuration file /etc/containers/registries.conf. You can edit and add different registries in the configuration file.
nano /etc/containers/registries.conf
Add the following lines at the end of the file:
[registries.search] registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
Save and close the file when you are finished.
Step 3 -Working with Podman
In this section, we will show you how to search and pull images and run a container with the Podman command.
To search for Debian-10 images, run the following command:
podman search debian-10
You should see all Debian 10 images in the following output:
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/dokken/debian-10 Debian 10 image for use with kitchen-dokken 0 docker.io docker.io/pythonpillow/debian-10-buster-x86 0 docker.io docker.io/diodonfrost/debian-10-ansible DEPRECATED - move to diodonfrost/ansible-deb... 0 docker.io docker.io/ingescape/debian-10-with-zyre 0 docker.io docker.io/alvistack/debian-10 0 docker.io docker.io/naparuba/debian-10-python3 0 docker.io docker.io/ursa/debian-10 0 docker.io docker.io/naparuba/debian-10 0 docker.io docker.io/opencpu/debian-10 OpenCPU server of Debian 10 0 docker.io docker.io/mesaguy/debian-10-kitchen-ansible-x86_64 Debian 10 image for testing Ansible playbook... 0 [OK] docker.io docker.io/mesaguy/debian-10-boot-x86_64 Debian 10 image, bootable for testing purpos... 0 [OK] docker.io docker.io/couchbasebuild/debian-10-gcc 0 docker.io docker.io/radarhere/debian-10-buster-x86 0 docker.io docker.io/nkbvs/debian-10_i386_cpp_base 0 docker.io docker.io/quentinjdu21/debian-10 0 docker.io docker.io/mitting/debian-10-web 0 docker.io docker.io/freehackquest/debian-10-for-cpp-build Docker with preinstalled g++, cmake, make, m... 0 docker.io docker.io/lbelmarletelier/debian-10-builder 0 docker.io docker.io/armpits/debian-10-armhf Docker import of minimal Debian chroot. 0 docker.io docker.io/arthurpicht/debian-10 Basic debian 10 "Buster" image with extended... 0
To download the Nginx image, run the following command:
podman pull nginx
You should see the following output:
✔ docker.io/library/nginx:latest Trying to pull docker.io/library/nginx:latest... Getting image source signatures Copying blob 596b1d696923 done Copying blob 8283eee92e2f done Copying blob 69692152171a done Copying blob febe5bd23e98 done Copying blob 351ad75a6cfa done Copying blob 30afc0b18f67 done Copying config d1a364dc54 done Writing manifest to image destination Storing signatures d1a364dc548d5357f0da3268c888e1971bbdb957ee3f028fe7194f1d61c6fdee
To list all downloaded images, run the following command:
podman images
You should see the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/nginx latest d1a364dc548d 2 weeks ago 137 MB
To create a new container from the Nginx image, run the following command:
podman run -dit nginx
You can now check the Nginx container with the following command:
podman ps
You should see the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c1692863973d docker.io/library/nginx:latest nginx -g daemon o... 20 seconds ago Up 19 seconds ago priceless_lewin
To create a new image from the running Nginx container, run the following command:
podman commit --author "Author Name Hitesh" c1692863973d docker.io/library/new-nginx
You should see the following output:
Getting image source signatures Copying blob 02c055ef67f5 skipped: already exists Copying blob 766fe2c3fc08 skipped: already exists Copying blob 83634f76e732 skipped: already exists Copying blob 134e19b2fac5 skipped: already exists Copying blob 5c865c78bc96 skipped: already exists Copying blob 075508cf8f04 skipped: already exists Copying blob af6431b8bf0b done Copying config bf2a70efe3 done Writing manifest to image destination Storing signatures bf2a70efe38f99b363f8f0b7dfd395d3aec81571ed03ac7b0898954379f16768
You can now check the newly created image with the following command:
podman images
You should see the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/new-nginx latest bf2a70efe38f 22 seconds ago 137 MB docker.io/library/nginx latest d1a364dc548d 2 weeks ago 137 MB
To stop the running container, run the following command:
podman stop container-id
To remove the running container, run the following command:
podman remove container-id
To stop and start the latest container, run the following command:
podman stop --latest podman start --latest
To remove the latest container, run the following command:
podman rm --latest
Conclusion
In the above guide, you learned how to install and use Podman on an Ubuntu server. Podman is a great tool for managing containers and images – give it a try on your dedicated server hosting account from Atlantic.Net. You can explore the Podman for more interesting features.