Podman also called "Pod Manager" is an open-source tool used for creating and managing containers. It is part of the libpod library that doesn’t rely on the Docker daemon and is compatible with Docker. It is a simple and lightweight container runtime environment for Kubernetes. With the recent change in Docker License, podman can become a good alternative available to use in most Linux Systems.
In this tutorial, I will show you how to install and use Podman on Ubuntu 22.04 server.
Prerequisites
- A server running Ubuntu 22.04.
- A root password is configured on the server.
Install Podman on Ubuntu 22.04
By default, the Podman package is included in the Ubuntu default repository. You can install it by just running the following command:
apt install podman -y
Once the Podman is installed, you can verify it with the following command:
podman -v
You should see the Podman version in the following output:
podman version 3.4.4
You can also see the detailed information about Podman with the following command:
podman info
You should get the following output:
host: arch: amd64 buildahVersion: 1.23.1 cgroupControllers: - cpuset - cpu - io - memory - hugetlb - pids - rdma - misc cgroupManager: systemd cgroupVersion: v2 conmon: package: 'conmon: /usr/bin/conmon' path: /usr/bin/conmon version: 'conmon version 2.0.25, commit: unknown' cpus: 2 distribution: codename: jammy distribution: ubuntu version: "22.04" eventLogger: journald hostname: ubuntu2204 idMappings:
Configure Podman Registry
By default, the Podman registry is not configured to download and install container images from the web. So you will need to configure it first.
nano /etc/containers/registries.conf
Add the following lines:
[registries.search] registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
Save and close the file when you are finished.
Download Images with Podman
Podman allows you to easily search and download images from the web. For example, to search a Debian image, run the following command:
podman search debian
You should get a list of all Debian images in the following output:
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/library/ubuntu Ubuntu is a Debian-based Linux operating sys... 14959 [OK] docker.io docker.io/library/debian Debian is a Linux distribution that's compos... 4435 [OK] docker.io docker.io/library/neurodebian NeuroDebian provides neuroscience research s... 93 [OK] docker.io docker.io/bitnami/debian-base-buildpack Debian base compilation image 2 [OK] docker.io docker.io/mirantis/debian-build-ubuntu-xenial 0 docker.io docker.io/mirantis/debian-build-ubuntu-trusty 0 docker.io docker.io/osrf/debian_arm64 Debian arm64 Base Images 1 docker.io docker.io/rancher/debianconsole 1 docker.io docker.io/dokken/debian-10 Debian 10 image for use with kitchen-dokken 0 docker.io docker.io/dokken/debian-9 Debian 9 image for kitchen-dokken 0 docker.io docker.io/ustclug/debian Official Debian Image with USTC Mirror 1 docker.io docker.io/dokken/debian-8 EOL: Debian 8 image for kitchen-dokken 0 docker.io docker.io/dokken/debian-11 Debian 11 image for use with kitchen-dokken 0 docker.io docker.io/corpusops/debian-bare https://github.com/corpusops/docker-images/ 0 docker.io docker.io/datadog/debian-i386 0 docker.io docker.io/corpusops/debian debian corpusops baseimage 0 docker.io docker.io/osrf/debian_armhf Debian Armhf Base Images 1 docker.io docker.io/treehouses/debian 2 docker.io docker.io/dokken/debian-7 EOL DISTRO: For use with kitchen-dokken, Bas... 0 docker.io docker.io/treehouses/debian-tags 0 docker.io docker.io/dokken/debian-12 0 docker.io docker.io/dockage/debian-runit Docker image uses runit as a process supervi... 2 [OK] docker.io docker.io/galaxy/debian32-wheel 0 docker.io docker.io/galaxy/debian-wheel 0 docker.io docker.io/dockage/debian Debian image that forms the base for some Do... 2 [OK]
Next, download the latest Debian image from the internet using the following command:
podman pull debian
This will search and download the latest Debian image as shown below:
Getting image source signatures Copying blob 23858da423a6 done Copying config 43d28810c1 done Writing manifest to image destination Storing signatures 43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a
You can now verify the downloaded image with the following command:
podman images
You should see the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/debian latest 43d28810c1b4 5 days ago 129 MB
Create and Manage Container Using Podman
With Podman, you can easily create and manage containers via the command line.
To create a container from the Debian image, run the following command:
podman run -dit --name debian-container debian
Once the container is created, you can see the running container with the following command:
podman ps
You should see the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 533698eaf6f1 docker.io/library/debian:latest bash 6 seconds ago Up 6 seconds ago debian-container
To connect to the Debian container, run the following command:
podman attach debian-container
You will get into the Debian container as shown below:
root@533698eaf6f1:/#
You can verify the container version with the following command:
cat /etc/os-release
You will get the following output:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
To exit from the container, run the following command:
root@533698eaf6f1:/# exit
To stop the container, run the following command:
podman stop debian-container
To start the container, run the following command:
podman start debian-container
To delete the container, run the following command:
podman rm debian-container
To delete the Debian image, run the following command:
podman rmi debian
You will get the following output:
Untagged: docker.io/library/debian:latest Deleted: 43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a
You can list all Podman command options with the following command:
podman --help
You should see all useful options in the following output:
Manage pods, containers and images Usage: podman [options] [command] Available Commands: attach Attach to a running container auto-update Auto update containers according to their auto-update policy build Build an image using instructions from Containerfiles commit Create new image based on the changed container container Manage containers cp Copy files/folders between a container and the local filesystem create Create but do not start a container diff Display the changes to the object's file system events Show podman events exec Run a process in a running container export Export container's filesystem contents as a tar archive generate Generate structured data based on containers, pods or volumes healthcheck Manage health checks on containers help Help about any command history Show history of a specified image image Manage images images List images in local storage import Import a tarball to create a filesystem image info Display podman system information init Initialize one or more containers inspect Display the configuration of object denoted by ID kill Kill one or more running containers with a specific signal load Load image(s) from a tar archive login Login to a container registry logout Logout of a container registry logs Fetch the logs of one or more containers machine Manage a virtual machine manifest Manipulate manifest lists and image indexes mount Mount a working container's root filesystem network Manage networks pause Pause all the processes in one or more containers play Play containers, pods or volumes from a structured file pod Manage pods port List port mappings or a specific mapping for the container ps List containers pull Pull an image from a registry push Push an image to a specified destination rename Rename an existing container restart Restart one or more containers rm Remove one or more containers rmi Removes one or more images from local storage run Run a command in a new container save Save image(s) to an archive search Search registry for image secret Manage secrets start Start one or more containers stats Display a live stream of container resource usage statistics stop Stop one or more containers system Manage podman tag Add an additional name to a local image top Display the running processes of a container unmount Unmounts working container's root filesystem unpause Unpause the processes in one or more containers unshare Run a command in a modified user namespace untag Remove a name from a local image version Display the Podman version information volume Manage volumes wait Block on one or more containers
Getting Started with Podman
A detailed guide on how to use Podman to create images, volumes, and containers is available here: Getting Started with Podman: Manage Images, Containers and Volumes
Conclusion
Congratulations! you have successfully installed Podman on Ubuntu 22.04 server. You can now use Podman as an alternate tool for Docker to manage the container. Feel free to ask me if you have any questions. For more information about Podman, visit the Podman documentation page.