Installing Podman on Ubuntu 22.04

Installing Podman on Ubuntu 22.04

In this comprehensive guide, we’ll walk you through the step-by-step process of installing Podman on Ubuntu 22.04, empowering you to leverage its capabilities for your projects.

Table of Contents

Introduction

As containerization continues to transform the landscape of software development and deployment, Podman emerges as a powerful alternative to Docker. Podman provides a lightweight and secure way to manage containers on Linux systems, offering features such as rootless containers and seamless integration with systemd.

Unlike Docker, Podman operates without a central daemon, eliminating potential single points of failure and reducing attack surfaces. Moreover, Podman’s compatibility with existing container images and workflows makes it an attractive choice for organizations seeking to modernize their infrastructure without overhauling their existing processes.

Why Choose Podman?

Before delving into the installation process, let’s explore some key reasons why Podman is gaining traction among developers and system administrators:

  • Rootless Containers: Podman allows users to run containers without requiring root privileges, enhancing security and minimizing the risk of privilege escalation attacks.

  • Compatibility with Docker: Podman provides a Docker-compatible command-line interface (CLI), enabling users familiar with Docker to seamlessly transition to Podman without a steep learning curve.

  • Systemd Integration: Podman integrates with systemd, enabling users to manage containers as systemd services, facilitating automation and orchestration tasks.

  • OCI Compatibility: Podman adheres to the Open Container Initiative (OCI) standards, ensuring compatibility with OCI-compliant container images and runtimes.

Installing Podman on Ubuntu 22.04: Step-by-Step Instructions

With these advantages in mind, let’s proceed to the installation steps.

Update your system

Before installing Podman, it’s essential to ensure that your Ubuntu system is up to date. Open a terminal and run the following commands:

				
					$ sudo apt update -y; sudo apt upgrade -y
				
			

Install Podman

Once your system is updated, you can proceed to install Podman. Run the following command to install Podman and its dependencies:

				
					$ sudo apt install podman -y
				
			

This command will download and install Podman along with any required packages.

Verify Podman Installation

After the installation is complete, you can verify that Podman is installed correctly by running the following command:

				
					$ podman --version
				
			
				
					podman version 3.4.4
				
			

This command should display the installed version of Podman, confirming a successful installation.

Installing Podman on Ubuntu 22.04: Get Started with Podman

Now that Podman is installed on your Ubuntu 22.04 system, you can start exploring its features and capabilities. Here are some basic commands to get you started:

Podman run

Launch a container from a specified image: In this instance, we will pull a web server image (NGINX) using Podman.

				
					$ podman pull docker.io/library/nginx
				
			

The Breakdown

  • “docker.io” is the registry where the image is hosted.
  • “library/nginx” is the name of the image.

By specifying the full image name along with its registry, Podman will be able to pull the image successfully.

				
					$ podman pull docker.io/library/nginx
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob c7f80e9cdab2 done  
Copying blob c3ea3344e711 done  
Copying blob e1caac4eb9d2 done  
Copying blob da8fa4352481 done  
Copying blob cc1bb4345a3a done  
Copying blob 88f6f236f401 done  
Copying blob 18a869624cb6 done  
Copying config e4720093a3 done  
Writing manifest to image destination
Storing signatures
e4720093a3c1381245b53a5a51b417963b3c4472d3f47fc301930a4f3b17666a

				
			

Once the image completes its successful download, we can proceed to the next step and create a detached container using this image.

				
					$ podman images
				
			
				
					REPOSITORY               TAG         IMAGE ID      CREATED     SIZE
docker.io/library/nginx  latest      e4720093a3c1  2 days ago  191 MB

				
			
				
					$ podman  run -d -p 8080:80 nginx
				
			

As evident, the container was created and assigned random names like (upbeat_shannon) due to the absence of a --name option during creation.

				
					$ podman ps

				
			
				
					CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS            PORTS                 NAMES
f0b180fab587  docker.io/library/nginx:latest  nginx -g daemon o...  6 seconds ago  Up 5 seconds ago  0.0.0.0:8080->80/tcp  upbeat_shannon

				
			

Using the --name option, we can name our container instances whatever we choose:

				
					$ podman ps
				
			
				
					$ podman run --name web_instance -d -p 8080:80 nginx
bb1a04e7d291045c628c5888daba716a69aef37e2adec922a4be0e6f1cd7b579


				
			
				
					CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS            PORTS                 NAMES
bb1a04e7d291  docker.io/library/nginx:latest  nginx -g daemon o...  5 seconds ago  Up 4 seconds ago  0.0.0.0:8080->80/tcp  web_instance
				
			

Note: To prevent conflict errors when creating multiple containers, it’s essential to ensure that port mappings and container names are distinct. In this particular case, we reused the same port mappings, as we had removed the original “upbeat_shannon” container (Visit Podman rm section below).

Podman container 'upbeat Shannon'

Photo by admingeek from Infotechys

Highlighted above in red, we observe the newly created container alongside the IP address of the host machine. This information will be necessary for the subsequent step.

NGINX Welcome Page

Photo by admingeek from Infotechys

The NGINX welcome page is displayed when the installation is successful, providing a clear indication that the web server is up and running. This default landing page not only confirms the successful deployment of NGINX but also serves as a starting point for further customization and development.

Podman rm (remove)

Once you’re done with the container, run the following command(s) to delete it!

				
					$ podman stop <container ID or Container Name>; podman rm <container ID or Container Name>
				
			

For instance, the following commands will remove the upbeat_shannon container.

				
					$ podman stop upbeat_shannon; podman rm upbeat_shannon
				
			
				
					upbeat_shannon
f0b180fab587bd9a6f309bf80cb1f34d80a8e2e785e56b07a9f913f230482073

				
			

To remove the image entirely, run the following commad: 

				
					$ podman images
				
			
				
					REPOSITORY               TAG         IMAGE ID      CREATED     SIZE
docker.io/library/nginx  latest      e4720093a3c1  2 days ago  191 MB
				
			
				
					$ podman rmi nginx


				
			

Configuring Registries

If you frequently use images from Docker Hub, you can set up an alias for the “docker.io” registry in Podman’s configuration. To do this, you can edit the “/etc/containers/registries.conf” file and add the following line:

				
					docker.io = ["docker.io"]
				
			

This configuration instructs Podman to use “docker.io” as an alias for the Docker Hub registry. After making this change, you should be able to pull images using short names without encountering an error.

Conclusion

Congratulations! You have successfully installed Docker on Ubuntu 22.04. With Docker up and running, you can now containerize your applications, streamline your development workflow, and deploy applications with ease. Docker’s versatility and efficiency make it a valuable tool for any developer or system administrator.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *