CentOSRHEL Based

How To Install Podman on CentOS Stream 10

Install Podman on CentOS Stream 10

Podman is an open-source container management tool that offers a familiar interface for creating, running, and managing containers. Built on top of Linux namespaces and cgroups, Podman leverages the Open Containers Initiative (OCI) standards to ensure high compatibility with container images. Unlike Docker, Podman runs in a daemonless manner, which means it works without a background server process. This design helps improve security and reduce potential vulnerabilities. CentOS Stream 10, with its rolling-release model, is an excellent environment for running Podman because it offers up-to-date packages, timely bug fixes, and strong community support. This guide explains how to install Podman on CentOS Stream 10, exploring everything from system requirements all the way to best practices for performance and security.

Introduction

Modern containerization has revolutionized how software is deployed. Teams favor containers for their efficiency, portability, and consistency across different environments. Podman stands out by providing a Docker-compatible command line, letting container enthusiasts comfortably switch from Docker to Podman without disrupting their workflows. Additionally, Podman’s support for rootless containers allows non-privileged users to manage containers securely, making it an attractive option for both beginners and enterprise-level operations. This comprehensive tutorial delves into the process of installing Podman on CentOS Stream 10 properly, ensuring a repeatable and efficient setup. In doing so, it explores each step in depth, discussing recommended configurations, common pitfalls, and best practices that enhance security and performance.

Before diving in, familiarity with the command line is beneficial for following the installation steps. Also, ensure you have root or sudo privileges to modify system configurations. By the end, the entire environment should be primed for container creation, addressing the needs of anyone who wants to streamline deployments and manage applications more effectively.

Prerequisites

Podman’s lightweight architecture makes it compatible with a broad range of systems, but there are certain prerequisites for smooth installation on CentOS Stream 10:

System Requirements

While Podman does not demand highly specialized hardware, an environment with at least 2 GB of RAM is advantageous for running a few containers comfortably. More RAM may be necessary if multiple containers are running simultaneously or if containers house resource-intensive services. It is recommended to have a dual-core processor for better performance, although single-core architectures can still handle smaller workloads. Finally, a stable internet connection is crucial so that repositories are accessible and package downloads do not fail halfway. Network-related issues frequently cause incomplete installations, so reliable connectivity makes the process smoother.

Software Requirements

Administration tasks such as package installations and system configurations require elevated privileges. Hence, having sudo access or root credentials is essential. Podman requires some dependencies to operate seamlessly, including standard support libraries for container runtimes and SELinux policy modules suited for container usage. While CentOS Stream 10 typically includes these libraries by default, ensuring the system is updated helps you avoid version mismatches. The underlying Linux kernel version also influences container operations, so any stable CentOS Stream 10 kernel version is recommended to meet Podman’s baseline requirements.

Ensure Sufficient Disk Space

Container images can be sizable. Homegrown or official container images vary in size, often ranging from a few hundred megabytes to multiple gigabytes. Verifying that the designated partition or filepath for storing images has adequate disk space is vital. It prevents future conflicts while pulling container images or running multiple containers simultaneously.

System Preparation

The next step is to prepare your CentOS Stream 10 system. Proper preparation minimizes errors and ensures that Podman operates optimally from the get-go.

Update System Packages

Regular system updates are a best practice on any Linux distribution. Updates include security patches, bug fixes, and any new features relevant to dependencies that Podman might need. To update your system packages, open a terminal and run:

sudo dnf update -y

This command synchronizes the local package index with the upstream repositories, fetching available updates and applying them. In a rolling-release distribution like CentOS Stream 10, such updates can include kernel improvements, new library versions, or security patches that improve overall stability for container engines.

Install Essential Dependencies

Certain foundational applications within Linux, such as tar, curl, or wget, are invaluable when fetching and unpacking additional software. To install or update essential utilities, you might run:

sudo dnf install -y tar curl wget git iproute

Some of these packages may already be installed. Still, running the command verifies they are up to date. Having these utilities ensures you do not run into “command not found” errors during the subsequent installation steps.

Optional SELinux Configuration

Most modern Red Hat-based distributions come with SELinux (Security-Enhanced Linux) enabled by default. Podman can run smoothly with SELinux constraints, but certain advanced setups—like mounting specific volumes—can benefit from additional SELinux rules. If any container images require modifications to SELinux contexts, the chcon or semanage fcontext commands can be used to fine-tune security policies. This additional step is not always mandatory, but an understanding of SELinux eases future troubleshooting if permission issues surface.

Reboot If Necessary

After updating the system, consider rebooting if a major kernel update was applied. A reboot ensures the new kernel takes effect and any pending system-level changes are committed. Use:

sudo reboot

Once the system restarts, verify again that everything is functioning as expected. Inspect logs or confirm that essential services are running normally before proceeding to install Podman.

Installation Process

The heart of this guide revolves around setting up Podman on CentOS Stream 10. CentOS Stream typically hosts Podman packages in its repositories, making the installation process straightforward.

Enable the Required Repositories

By default, CentOS Stream 10 includes certain official repositories that are kept up to date. However, additional repositories or streams might sometimes contain the latest stable Podman releases. To ensure you receive the newest official version, verify if your system has the required repositories enabled:

sudo dnf repolist

If necessary, enable any needed extra repositories. For instance, if the container tools repository is not enabled, run:

sudo dnf config-manager --set-enabled centos-stream-extras

This ensures that Podman and its required libraries are readily available.

Install Podman via DNF

After confirming the availability of official repositories, the installation step is quite simple. The dnf package manager quickly handles dependencies for you. To install Podman:

sudo dnf install -y podman

This command retrieves Podman and any necessary dependencies, such as runc and conmon. Once the installation completes, you can verify its success by checking the version:

podman --version

The output displays the currently installed Podman version, ensuring everything went smoothly.

Installation Verification

At this point, it is essential to ensure Podman is working properly. Run a basic container pull-and-run test. For instance, pulling the official hello-world image:

podman pull hello-world
podman run hello-world

If the output indicates “Hello from Docker!” or a similar greeting, Podman successfully ran the container and you are set. This step is valuable for guaranteeing no underlying conflicts exist in your environment, especially if you have installed or used Docker in the past.

Handling Potential Conflicts with Docker

In some scenarios, Docker might have been installed on the same system. While Docker and Podman can coexist in certain configurations, it is often simpler to remove Docker-related software or stop Docker services to minimize confusion in network bridging or container runtime conflicts. Use:

sudo systemctl disable docker --now
sudo dnf remove docker docker-client docker-client-latest

This ensures there are no pinned container daemons obstructing Podman’s normal operation.

Confirming SELinux Policies

On Red Hat-based systems like CentOS Stream, SELinux plays a fundamental security role. Ensure SELinux is configured in a way that does not restrict container operations. Run:

getenforce

If this returns Enforcing, Podman typically works fine. If uncommon permission errors occur, a disciplined approach is to adjust SELinux policies specifically for containers rather than disabling SELinux altogether. In most default configurations, special changes are not required at the installation stage.

Post-Installation Configuration

With Podman installed, the next step is to configure the environment for the best possible container management experience. While Podman’s default settings suit many scenarios, a few tweaks can enhance performance, security, and convenience.

Configuring Storage

Podman uses containers/storage under the hood to store images and container layers. By default, these are often located in /var/lib/containers. If running multiple containers or storing large images, consider placing this directory on a partition with ample disk space. To do so, you can use bind mounts or symlinks, for example:

sudo systemctl stop podman
sudo mv /var/lib/containers /new_storage_location/containers
sudo ln -s /new_storage_location/containers /var/lib/containers
sudo systemctl start podman

Ensuring the receiving partition has the same SELinux context or adjusting contexts accordingly prevents permission-related issues.

Networking Configuration

Podman supports various networking modes such as bridge, host, and none. By default, Podman creates a default bridge network (generally cni-podman0 or a similarly named interface) if you have packages like containernetworking-plugins installed. This setting allows containers to communicate with each other on an isolated network, bridging to the host for external access. To tailor the default network, modify the /etc/cni/net.d/ files, or create new networks using podman network create. For instance:

podman network create my-custom-network

This new named network can host one or more containers, giving them specific IP ranges or advanced network configurations. Remember to test connectivity among containers and the host once configured, ensuring firewall rules do not interfere with the container traffic.

Rootless Containers and User Permissions

One of Podman’s hallmark features is its ability to run containers as a non-root user, making your system less susceptible to intrusions if a container is compromised. To configure rootless mode, verify that your user has a sufficient range of user and group IDs mapped in /etc/subuid and /etc/subgid. If these files are missing or empty, add lines like:

yourusername:100000:65536

Adjust the ranges appropriately based on your environment’s needs. Next, enabling user namespaces fosters an environment in which the container’s root user is merely a regular user on the host system. This significantly reduces risk without sacrificing container functionality.

Basic Usage Guide

With Podman up and running, the next step is to understand its primary commands and container lifecycle. These commands are largely similar to Docker equivalents, making the transition straightforward.

Pulling Container Images

All container workflows start by pulling container images from a registry, with the default registry being Docker Hub. For instance, to pull the latest Ubuntu image:

podman pull ubuntu:latest

The command fetches the image layers, storing them on your local system. If you prefer a different registry, specify it explicitly, for example:

podman pull registry.fedoraproject.org/fedora:latest

Once pulled, the images become available locally and can be used immediately to spawn containers.

Running Containers

Running a container is as simple as pulling an image. The following command runs a new Ubuntu-based container in interactive mode with a terminal prompt:

podman run -it ubuntu:latest /bin/bash

Upon exit, the container stops. If you want it to continually run in the background, you can run a service or use the -d (detach) option. For instance, to run an NGINX web server container:

podman run -d -p 80:80 nginx:latest

This publishes port 80 from the container to port 80 on the host, enabling external traffic to reach the containerized web server.

Managing Images and Containers

Podman offers a suite of commands for orchestrating containers. Use podman ps to list running containers. To see both running and stopped containers, include -a:

podman ps -a

Stopping a container is equally straightforward. For example:

podman stop <container-id>

The podman rm command removes a container, while podman rmi removes an image. Periodic cleanup prevents clutter and frees up disk space, particularly important for environments that spin up containers frequently.

Advanced Configuration

Once the basics are mastered, diving into advanced Podman configurations can enhance performance and tighten security. These adjustments are especially important for production-level deployments.

Performance Optimization

For container-heavy workloads, refining performance is key. Consider using cgroups v2, which is the default configuration on many newer Linux distributions. This helps with fine-grained resource isolation and scheduling. Also, employing OverlayFS as the storage driver often yields better performance than alternatives, though it may require verifying kernel support. Tuning file system settings, such as read-ahead buffers, can yield noticeable performance benefits for I/O-intensive containers.

Security Settings

In addition to rootless containers, Podman’s tight integration with SELinux can block unauthorized container actions. Tools like podman-seccomp can further filter system calls, providing an additional layer of protection. Another best practice is to utilize podman inspect to examine container configurations for potential open vulnerabilities like over-privileged containers or unprotected ports. Deploying containers behind a firewall and segregating container networks further mitigates security risks.

Troubleshooting Common Issues

Even with a well-structured process, issues can sometimes arise. Below are common scenarios and their possible fixes.

Installation Errors

Occasionally, the package manager might fail to locate the Podman package, particularly if the relevant repositories were nor properly enabled or if the package index is out of date. Double-check repository configurations and run sudo dnf clean all followed by sudo dnf update. If the issue persists, confirm your system date and time are correct, as out-of-sync clocks can disrupt secure connections to repositories.

Permission Problems

Users sometimes encounter permissions-related errors when operating rootless containers. Confirm that /etc/subuid and /etc/subgid have the user mappings, and ensure your user is part of relevant groups. If containers still face mounting issues, adjust SELinux labels or run restorecon on container directories. This step ensures SELinux recognizes the correct file contexts for container usage.

Network Connectivity Issues

If containers cannot access external networks, reevaluate whether firewall settings block outbound connections. Tools like firewall-cmd can be used to adjust or review the active firewall zones. Also, confirm that cni-podman0 or other Podman network interfaces exist and have correct IP assignments. Recreating the default Podman network could resolve unusual conflicts that hamper container communications.

Best Practices

CentOS Stream 10 mixed with Podman provides a powerful platform, but following certain best practices can enhance smooth operations and minimize errors over time.

Security Considerations

Always run containers with the least privilege principle. Unless it is essential, avoid passing the --privileged flag. Conduct routine audits of container images to verify that the software packages inside them are updated. Using official or trusted registry sources further reduces the risk of unwittingly downloading malicious or outdated images.

Performance Optimization

Regularly clear unused images and stopped containers. The podman system prune command helps keep your environment tidy, preventing wasted disk space and avoiding clutter. Also, consider container-specific resource limits (e.g., --cpus or --memory) to keep resource-intensive containers from overwhelming the host system.

Regular Maintenance

CentOS Stream 10 follows a rolling-release approach. Regularly updating the platform ensures kernel improvements and security patches are applied. Coupled with scheduled container updates, this helps maintain reliability. For extensive deployments, version locking in dnf can keep container environments consistent across multiple servers or clusters.

Congratulations! You have successfully installed Podman. Thanks for using this tutorial for installing Podman containers on your CentOS Stream 10 system. For additional help or useful information, we recommend you check the official Podman website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button