Install Podman on AlmaLinux 9: Easy Container Manager

Posted on

Install Podman on AlmaLinux 9: Easy Container Manager

This guide, brought to you by Orcacore, will walk you through the process of how to Install Podman on AlmaLinux 9. Podman is an open-source, Linux-native tool designed for developing, managing, and running containers and pods in accordance with the Open Container Initiative (OCI) standards. Developed by Red Hat as a user-friendly container orchestrator, Podman is the default container engine in RedHat 8 and CentOS 8.

Podman is part of a suite of command-line tools designed to handle various aspects of the containerization process, offering a modular framework. This set includes:

  • Buildah: For building OCI-compliant images.
  • Skopeo: For inspecting and transferring container images between different registries.
  • Crun: A fast and lightweight OCI runtime.

These tools are designed to work with any OCI-compatible container engine, including Docker, simplifying the transition to Podman or enabling its use alongside an existing Docker installation. It allows you to Install Podman on AlmaLinux 9 without the need to replace Docker completely.

Steps To Install and Use Podman on AlmaLinux 9

To follow this guide, you should be logged into your AlmaLinux 9 server as a non-root user with sudo privileges. You can refer to Orcacore’s guide on Initial Server Setup with AlmaLinux 9 for instructions on how to set up such a user.

1. Install Podman on AlmaLinux 9

First, update your system’s package index and upgrade any existing packages to their latest versions:

sudo dnf update && sudo dnf upgrade

Podman packages are readily available in the default AlmaLinux repository. To install Podman, execute the following command:

sudo dnf install podman -y

After installation, verify the Podman version to confirm that it was installed successfully:

podman --version
**Output**
podman version 4.2.0

Start and Enable Podman Service

While Podman itself is daemonless, systemd unit files can manage containers. Start and enable the Podman service using these commands:

# sudo systemctl start podman
# sudo systemctl enable podman

Check the status of the Podman service to ensure it is active and running:

sudo systemctl status podman
Install Podman on AlmaLinux 9 - Chech Podman status

For detailed information about your Podman installation and its configuration, use the podman info command:

podman info

With Podman successfully installed, you can proceed to set up Podman Compose.

2. Set up Podman Compose on AlmaLinux 9

Podman Compose allows you to use docker-compose.yml files with Podman, providing a drop-in replacement for Docker Compose. This can be useful to Install Podman on AlmaLinux 9 while still using existing Compose files.

First, enable the Extra Packages for Enterprise Linux (EPEL) repository:

sudo dnf install epel-release -y

Then, install Podman Compose:

sudo dnf install podman-compose -y

Use docker as a command tool instead of Podman (optional)

If you prefer to use the docker command-line tool with Podman, you can install the podman-docker package.

sudo dnf install podman-docker

This allows you to use familiar docker commands, while Podman executes them in the background.

Verify the installation by checking the version:

podman -v
or
docker -v

Both commands should produce the same output:

**Output**
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
podman version 4.2.0

3. Use Podman on AlmaLinux 9

Now that you have installed Podman, let’s explore its basic usage.

Search and pull images with Podman

Similar to Docker, you can use Podman to search for container images from different registries.

For example, to search for AlmaLinux images, use the following command:

podman search almalinux

To download and pull an image, use the podman pull command:

podman pull almalinux

List all Images with Podman

To view a list of all available images on your system, use the podman images command:

podman images

Example output:

**Output**
REPOSITORY                   TAG         IMAGE ID      CREATED      SIZE
docker.io/library/almalinux  latest      acaca326f3b3  6 weeks ago  196 MB

Create a Container with Podman

Once you have an image, you can create a container from it. Here’s how to create a container from the AlmaLinux image:

podman run -dit --name orca almalinux
  • -d: Runs the container in detached mode (background).
  • -i: Keeps STDIN open even if not attached.
  • -t: Allocates a pseudo-TTY.
  • –name: Assigns a name to the container.

To access the container’s command line, use the podman attach command:

podman attach orca

The command prompt will change to reflect the container ID:

daniel@82512000164c:/#

To start an existing container, use the following command:

podman start container-id or name

To stop a running container, use this command:

podman stop container-id or name

For more comprehensive information, refer to the Podman Documentation page.

Conclusion

You have now learned how to Install Podman on AlmaLinux 9 and perform basic container management tasks. Podman is a powerful, daemonless container engine that provides a secure and rootless alternative to Docker. It’s a great tool for developing and deploying containerized applications on AlmaLinux 9.

Here are some related articles that you might find interesting:

Alternative Solutions to Install Podman on AlmaLinux 9

While the article outlines the standard method for installing Podman on AlmaLinux 9 using the dnf package manager, here are two alternative approaches, along with their explanations and code examples:

1. Using a Custom Repository

Instead of relying solely on the default AlmaLinux repositories, you can configure a custom repository that might provide more up-to-date versions of Podman or specific builds tailored to your needs.

Explanation:

This approach involves adding a new repository definition file to your system that points to a specific location containing Podman packages. This is especially useful if you need a version of Podman that is newer than what’s available in the default repositories or if you’re working with a specialized distribution.

Steps:

  1. Identify the Repository: Find a suitable repository containing the desired Podman version. This could be a third-party repository or one you’ve created yourself. The example below assumes we are using a hypothetical repository.

  2. Create a Repository File: Create a .repo file in the /etc/yum.repos.d/ directory. For example, podman-custom.repo:

    sudo nano /etc/yum.repos.d/podman-custom.repo
  3. Add Repository Configuration: Add the repository configuration to the file. Replace the baseurl, gpgkey, and description with the actual values for your chosen repository.

    [podman-custom]
    name=Podman Custom Repository
    baseurl=https://example.com/podman/almalinux9/
    enabled=1
    gpgcheck=1
    gpgkey=https://example.com/podman/almalinux9/gpgkey
    description=Custom Podman builds for AlmaLinux 9
  4. Install Podman: After adding the repository, update the package cache and install Podman:

    sudo dnf update
    sudo dnf install podman -y

Considerations:

  • Ensure the repository you’re using is trusted and maintained.
  • Verify that the GPG key matches the repository to ensure package integrity.
  • Be aware that using custom repositories can introduce compatibility issues if not managed carefully.

2. Building from Source

Another alternative is to download the Podman source code and compile it yourself.

Explanation:

Building from source gives you complete control over the compilation process, allowing you to customize build options, apply patches, and ensure compatibility with your specific system configuration.

Steps:

  1. Install Dependencies: Ensure that you have all the necessary build dependencies installed. This typically includes Go, Make, and other development tools.

    sudo dnf install git make gcc golang -y
  2. Download Source Code: Download the Podman source code from the official GitHub repository:

    git clone https://github.com/containers/podman.git
    cd podman
  3. Checkout the desired release tag:

    git checkout v4.2.0
  4. Build Podman: Build Podman using the make command:

    make
    sudo make install

Considerations:

  • Building from source can be time-consuming, especially on slower systems.
  • You’ll need to manage dependencies and ensure they are compatible.
  • The resulting installation might not be managed by the package manager, so updates will need to be handled manually.

These alternative solutions offer more flexibility and control over the Podman installation process, but they also require more technical expertise and carry additional risks. The standard dnf installation method outlined in the original article is generally the recommended approach for most users due to its simplicity and ease of maintenance.