Install Podman on Centos 7 | Best Docker Alternative
In this guide, we’ll explore How To Install Podman on Centos 7. Podman is an open-source container management tool designed for developing, managing, and running OCI containers. It’s gaining popularity as a Docker alternative due to its daemon-less architecture and focus on security. Here are some of the advantages of using Podman:
- Daemon-less Architecture: Podman doesn’t require a daemon to run containers, which reduces resource consumption and eliminates a single point of failure.
- Rootless Containers: Podman supports running containers without root privileges, enhancing security and minimizing the impact of potential vulnerabilities.
- Docker Compatibility: Podman is largely compatible with Docker commands and images, making it easy to transition from Docker to Podman.
- Improved Security: By removing the daemon and enabling rootless containers, Podman significantly improves container security.
You can now proceed to the guide steps below to set up Install Podman on Centos 7.
Steps To Install and Use Podman on Centos 7
To complete this guide, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Centos 7
Install Podman on Centos 7
First, you need to update your local package index with the following command:
sudo yum update -y
Then, you need to install the Epel repository on your Centos 7 server by using the command below:
sudo yum install epel-release -y
Now you can use the following command to Install Podman on Centos 7:
sudo yum install podman -y
Then, verify your installation by checking its version:
podman --version

To get full information about Podman, you can use:
podman info

When your installation is completed, you can proceed to the next step to see how to use Podman.
How To Use Podman on Centos 7?
Now that you have installed Podman on your server let’s see How To Use Podman.
Search and pull images with Podman
Just like Docker, you can use the Podman command line to search Images but from different repositories. For example, if you want to install a Centos container using Podman, then you can search what are the images available through the different repositories.
podman search centos
Then, you can download and pull images with the following command:
podman pull centos
List all Images with Podman
If you have downloaded multiple images and now want to see what are the available images on your system, you can list all of them using the following command:
podman images
In my case:
**Output**
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/centos latest 5d0da3dc9764 13 months ago 239 MB
Create a Container with Podman
Once you have the image of the application that you want, you can create a container with it. Here we have downloaded the Centos image with Podman. Now we will show how to use it to create a container using Centos Image.
To do this, you can use the following command:
podman run -dit --name orca centos
Note: –name
is a parameter to give the container whatever friendly name you want to assign.
To access your Container command line, use the following command:
podman attach orca
You will see that your command prompt changes to your container ID:
[daniel@f420884c0802 /]#
To start your container, you can use the command below:
podman start container-id or name
To stop your container, you can use the following command:
podman stop container-id or name
For more information, you can visit the Podman Documentation page.
Conclusion
At this point, you have learned to Install Podman on Centos 7. Podman on Centos 7 is used to run and manage containers as a Docker alternative without a daemon, enhancing security and performance. It is a great alternative for containerisation.
Hope you enjoy it. You may also like these articles:
Install and Use Podman on AlmaLinux 8
Install and Use Podman on Debian 11
Alternative Solutions for Installing and Managing Containers on CentOS 7
While the provided guide effectively demonstrates how to install and use Podman on CentOS 7, it’s beneficial to explore alternative methods for containerization, especially considering the evolving landscape of container technologies. Here are two distinct approaches: using Buildah for image creation and leveraging LXC/LXD containers.
1. Building Container Images with Buildah
Buildah is another open-source tool from the same team that develops Podman. It focuses specifically on building OCI-compliant container images. Unlike Docker, which requires a daemon to build images, Buildah operates in a daemon-less fashion, similar to Podman. This makes it more secure and lightweight. Furthermore, Buildah allows you to build images directly from a Dockerfile or from scratch using commands.
Why Choose Buildah over Dockerfile Build?
- Daemon-less: No daemon means less resource consumption and a smaller attack surface.
- Scriptable: Buildah’s commands can be easily incorporated into shell scripts or CI/CD pipelines for automated image creation.
- Image Layer Manipulation: Buildah allows granular control over image layers, enabling you to add, modify, or remove layers as needed.
- Rootless Builds: Buildah can be used to build images without root privileges.
Installation on CentOS 7:
First, enable the necessary repositories:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_7/devel:kubic:libcontainers:stable.repo
sudo yum install -y buildah
Example Usage: Building an Image from Scratch
This example demonstrates building a simple image containing httpd
(Apache web server).
#!/bin/bash
# Create a working container
container=$(buildah from scratch)
# Mount the container
mountpoint=$(buildah mount $container)
# Install httpd and other dependencies
yum -y --installroot $mountpoint install httpd
# Create a simple index.html file
echo "<h1>Hello from Buildah!</h1>" > $mountpoint/var/www/html/index.html
# Unmount the container
buildah unmount $container
# Commit the container to an image
image_name="my-httpd-image"
buildah commit $container $image_name
# Clean up the container
buildah rm $container
echo "Image '$image_name' created successfully."
# You can now use this image with Podman or Docker
# podman run -d -p 80:80 $image_name
Explanation:
buildah from scratch
: Creates an empty container to start with.buildah mount
: Mounts the container’s filesystem to a directory on the host.yum -y --installroot $mountpoint install httpd
: Installshttpd
within the mounted container’s filesystem.echo ... > $mountpoint/var/www/html/index.html
: Creates a simple HTML file.buildah unmount
: Unmounts the container’s filesystem.buildah commit
: Commits the changes to create a new image.buildah rm
: Removes the working container.
This approach gives you fine-grained control over the image creation process and can be easily integrated into scripting workflows.
2. Containerization with LXC/LXD
LXC (Linux Containers) is an operating-system-level virtualization environment for running multiple isolated Linux systems (containers) on a single host. LXD is a next-generation system container manager built on top of LXC, offering a simpler and more user-friendly experience. Unlike Docker and Podman, which focus on application containers, LXC/LXD provides full system containers, more akin to lightweight virtual machines.
Why Choose LXC/LXD?
- Full System Containers: LXC/LXD containers offer a complete operating system environment, allowing you to run services that might not be well-suited for application containers.
- Performance: LXC containers often exhibit near-native performance since they directly use the host kernel.
- Isolation: LXC/LXD provides strong isolation between containers.
Installation on CentOS 7:
Because LXD is not readily available in the standard CentOS 7 repositories, you’ll need to use Snap to install it. First, install Snap:
sudo yum install epel-release -y
sudo yum install snapd -y
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
Then, install LXD:
sudo snap install lxd
sudo /snap/bin/lxd init # Follow the prompts to configure LXD
Example Usage: Creating and Running a CentOS 7 Container
# Launch a CentOS 7 container
lxc launch images:centos/7 my-centos-container
# List containers
lxc list
# Access the container's shell
lxc exec my-centos-container bash
# Stop the container
lxc stop my-centos-container
# Start the container
lxc start my-centos-container
# Delete the container
lxc delete my-centos-container
Explanation:
lxc launch images:centos/7 my-centos-container
: Creates a new container named "my-centos-container" based on the CentOS 7 image.images:
refers to the image server.lxc list
: Shows a list of running containers.lxc exec my-centos-container bash
: Opens a bash shell within the container. You can now run commands inside the isolated environment.lxc stop
andlxc start
: Stop and start the container.lxc delete
: Destroys the container.
LXC/LXD is a powerful alternative when you require full system containers with strong isolation and near-native performance. It’s suitable for scenarios where you need to run services that have complex dependencies or require a complete operating system environment.
By exploring Buildah and LXC/LXD, you expand your toolkit for containerization on CentOS 7 and can choose the most appropriate technology based on your specific needs and requirements. While Podman is an excellent Docker alternative for application containers, Buildah offers greater control over image creation, and LXC/LXD provides a solution for full system containerization. Understanding these alternatives allows for a more informed decision-making process when choosing a containerization strategy.