Install Podman on Rocky Linux 9

Install Podman on Rocky Linux 9

Learn how to install Podman on Rocky Linux 9 with this step-by-step guide. Discover essential commands, advanced features, troubleshooting tips, and system integration techniques to efficiently manage containers on your system.

Table of Contents

Introduction

Podman is a powerful container management tool that offers a similar experience to Docker but with a key difference — Podman does not require a central daemon to run. It’s designed to be daemonless, which enhances security and simplicity. If you’re using Rocky Linux 9, a RHEL-based distribution known for its stability and performance, installing and managing containers with Podman can significantly improve your workflow, especially when managing containerized applications.

This guide will walk you through the process of installing Podman on Rocky Linux 9. Whether you’re a developer, system administrator, or IT professional, this comprehensive tutorial will provide you with all the steps you need to get Podman up and running on your system.

Why Choose Podman Over Docker?

Before we dive into the installation process, let’s take a moment to understand why Podman is gaining popularity as an alternative to Docker.

Key Differences Between Podman and Docker

FeaturePodmanDocker
DaemonlessYes, no background daemon requiredRequires a central daemon (dockerd)
Rootless ContainersSupports rootless container executionDocker requires root privileges for most actions
CLI CompatibilityFully compatible with Docker CLIFully compatible with Docker CLI
System IntegrationIntegrates with systemd for better managementRequires Docker daemon service
SecurityImproved security (no root requirement)Less secure when using root privileges

Why Podman?

  • Daemonless Architecture: Podman does not require a background daemon. This reduces system overhead and improves security, as each container is run as a separate process.
  • Rootless Containers: Podman can be used to run containers without requiring root privileges. This feature makes Podman a more secure choice in multi-user environments.
  • Docker CLI Compatibility: Podman’s command-line interface is designed to be Docker-compatible, meaning most Docker commands can be used directly with Podman.
  • Systemd Integration: Podman integrates seamlessly with systemd, enabling easy management of containerized applications as services.

Podman is ideal for both individual developers and large-scale production environments, making it a perfect fit for Rocky Linux 9.

Prerequisites

Before you begin the installation, ensure you meet the following prerequisites:

    1. Rocky Linux 9 System: This guide assumes that you are running Rocky Linux 9 or a similar RHEL-based distribution.
    2. Root Privileges: You will need root or sudo privileges to install software on your system.
    3. Internet Access: You will need an active internet connection to download the necessary packages and dependencies.

Installing Podman on Rocky Linux 9

Installing Podman on Rocky Linux 9 is straightforward, thanks to the EPEL repository and the dnf package manager.

Step 1: Update Your System

Start by updating your system to ensure all existing packages are up to date. Open a terminal and run the following command:

				
					sudo dnf update -y
				
			
Install Podman on Rocky Linux 9

Photo by admingeek from Infotechys

This command will update all the installed packages to their latest versions.

Step 2: Enable EPEL Repository

Podman is available in the EPEL (Extra Packages for Enterprise Linux) repository, which is not enabled by default in Rocky Linux 9. To enable EPEL, run the following command:

				
					sudo dnf install epel-release -y
				
			

This will install the EPEL repository configuration, enabling you to access additional packages.

Step 3: Install Podman

Now that the EPEL repository is enabled, you can install Podman using the dnf package manager. Run the following command to install Podman:

				
					sudo dnf install podman -y
				
			

This will install Podman and all its dependencies on your system. Once the installation is complete, you can verify that Podman was installed successfully by checking its version:

				
					podman --version
				
			
				
					podman version 5.2.2
				
			

The output should display the installed version of Podman, indicating that the installation was successful.

Step 4: Start and Enable Podman Services

Since Podman is daemonless, it doesn’t require a central service to run. However, it does integrate well with systemd for managing containerized applications. If you want to use Podman to manage containers as systemd services, you’ll need to ensure that systemd is configured correctly.

 Podman’s integration with systemd is automatic, so no additional setup is required.

Using Podman: Basic Commands

After installing Podman, it’s time to start using it. Here are some of the basic commands you will use frequently when working with Podman:

1. Run a Container

To run a container, use the podman run command. For example, to run an instance of the nginx container:

				
					podman run -d -p 8080:80 --name nginx-container nginx
				
			
				
					Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob 566e42bcee1c done   | 
Copying blob da8cc133ff82 done   | 
Copying blob 2b99b9c5d9e5 done   | 
Copying blob bd98674871f5 done   | 
Copying blob 1e109dd2a0d7 done   | 
Copying blob fd674058ff8f done   | 
Copying blob c44f27309ea1 done   | 
Copying config f876bfc1cc done   | 
Writing manifest to image destination
c30c33d6ed85316b59048950c0caa32f5df4a284b018f734a1e8f556150ac3f1
				
			

This command will run the nginx container in detached mode (-d), expose port 8080 on your host, and map it to port 80 on the container.

NOTE: Select the docker.io/library registry if you don’t have a Redhat account. The Redhat registries require that you login using podman login with your Redhat credentials to gain access.

2. List Running Containers

To list all running containers, use the podman ps command:

				
					podman ps
				
			
				
					CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS         PORTS                         NAMES
c30c33d6ed85  docker.io/library/nginx:latest  nginx -g daemon o...  29 minutes ago  Up 29 minutes  0.0.0.0:8080->80/tcp, 80/tcp  nginx-container

				
			

This will display all the containers currently running on your system.

3. Stop a Container

To stop a container, use the podman stop command followed by the container name or ID:

				
					podman stop nginx-container
				
			

You only need the first few characters of the Container ID: c30 (in this example) when referring to the container.

4. Remove a Container

To remove a container, use the podman rm command. Make sure the container is stopped before removing it:

				
					podman rm nginx-container
				
			

5. Pull an Image

To pull a container image from a container registry (like Docker Hub), use the podman pull command:

				
					podman pull nginx
				
			

This will download the latest version of the nginx image.

Configuring Podman

Podman can be configured for various use cases, including rootless container management and systemd integration. Here are some configuration tips:

1. Rootless Containers

Podman supports rootless containers, which allows users to run containers without root privileges. This is enabled by default when running Podman as a non-root user. To verify that you can run containers without root access, simply try running the following command as a regular user:

				
					podman run -d nginx
				
			

If successful, Podman is working in rootless mode.

2. Systemd Integration

Podman integrates well with systemd for managing containerized applications as services. For example, to run a containerized service with systemd, you can generate a systemd unit file using the following command:

				
					sudo podman generate systemd --name nginx-container > /etc/systemd/system/nginx-container.service
				
			

After generating the service file, you can enable and start the service with systemd:

				
					sudo systemctl enable --now nginx-container
				
			

NOTE: The podman generate systemd command is DEPRECATED: It is recommended to use Quadlets for running containers and pods under systemd.

Working with Containers

Once you’ve installed and configured Podman, you’ll likely use it to manage various containers. Below are some advanced tips to manage containers effectively.

1. Podman Pod

A Pod is a group of containers that share the same network namespace. To create a pod with Podman:

				
					podman pod create --name my-pod -p 8080:80
				
			

2. Running Containers in the Background

To run containers in the background, use the -d flag. This allows your containers to run as background processes:

				
					podman run -d nginx
				
			

3. View Container Logs

To view the logs of a running container:

				
					podman logs nginx-container
				
			

Advanced Podman Features

Podman offers several advanced features, such as:

  • Podman Build: For building container images from a Dockerfile.
  • Podman Volume: To manage persistent storage volumes for containers.
  • Podman Push and Pull: To push container images to and pull them from container registries.

Example: Build a Container Image

To build a container image from a Dockerfile:

				
					podman build -t my-image /path/to/Dockerfile
				
			

Troubleshooting Podman Installation

If you encounter any issues while installing or using Podman on Rocky Linux 9, here are some troubleshooting tips:

StepActionDescription
Check Podman VersionRun podman --versionEnsure that you have the latest version of Podman installed.
Verify EPEL RepositoryMake sure the EPEL repository is enabled correctly.Verify that the EPEL (Extra Packages for Enterprise Linux) repository is set up properly.
Check Firewall SettingsVerify that necessary ports (e.g., port 8080 for web containers) are allowed.Ensure your firewall configuration allows access to the required container ports.
Review LogsCheck Podman logs for potential errors.Examine logs to troubleshoot any issues with container behavior or performance.

Conclusion

Podman is an efficient, secure, and flexible container management tool that integrates seamlessly with Rocky Linux 9. Its daemonless and rootless architecture makes it a powerful alternative to Docker, particularly in terms of security and ease of use. In this guide, we’ve walked through the installation process, basic usage, and advanced configuration of Podman on Rocky Linux 9.

By following this guide, you should be able to confidently install and manage containers using Podman, making it an ideal choice for developers and system administrators alike.

Did you find this article useful? Your feedback is invaluable to us! Please feel free to share your thoughts in the comments section below. Also, share this post!

Related Posts

Leave a Reply

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