How to Install and Use Podman on Arch Linux

How to Install and Use Podman on Arch Linux

Containerization has become a core element of modern Linux workflows, particularly for developers, system administrators, and DevOps engineers. While Docker has been the dominant player in this space, Podman has emerged as a powerful and secure alternative. Podman offers a daemonless, rootless container experience that aligns well with the UNIX philosophy of simplicity and modularity.

In this article, we’ll explore how to install Podman on Arch Linux, configure it for rootless usage, and go through the essential commands to manage containers and images effectively.


What is Podman?

Podman is a container engine developed by Red Hat as part of the libpod project. It provides a Docker-compatible command-line interface, allowing users to run, build, and manage containers and container images.

Key Features of Podman

  • Daemonless architecture: No background service required to run containers.
  • Rootless containers: Run containers as a regular user without needing sudo.
  • Docker CLI compatibility: Supports alias docker=podman for drop-in replacement.
  • Pods support: Allows grouping of multiple containers together.
  • OCI compliance: Uses Open Container Initiative standards for images and runtime.

Prerequisites

Before proceeding, ensure the following:

  • You are running Arch Linux or an Arch-based distribution like Manjaro.

  • You have a user account with sudo privileges.

  • Your system is up to date:

    sudo pacman -Syu
    

Step 1: Installing Podman on Arch Linux

Installing Podman on Arch is straightforward thanks to the availability in the official repositories.

1. Install Podman

sudo pacman -S podman

This command installs podman along with its dependencies, including conmon and runc.

2. Verify Installation

Once installed, verify that podman is available:

podman --version

Example output:

podman version 5.0.0

Step 2: Configuring Podman for Rootless Use

Podman shines in its ability to run containers without requiring root access. This feature improves security and isolation.

1. Add Subuid and Subgid Entries

Podman uses user namespaces for rootless containers. You need to assign a range of subordinate user and group IDs to your user.

Edit /etc/subuid and /etc/subgid:

sudo nano /etc/subuid

Add the following line (replace yourusername with your actual username):

yourusername:100000:65536

Then edit /etc/subgid similarly:

sudo nano /etc/subgid
yourusername:100000:65536

2. Enable user namespaces

Make sure user namespaces are enabled in the kernel:

zcat /proc/config.gz | grep USER_NS

You should see:

CONFIG_USER_NS=y

If it’s not enabled (rare in Arch), you may need a custom kernel.

3. Test Rootless Podman

You can now run a container without root:

podman run --rm alpine echo "Hello from rootless container"

Expected output:

Hello from rootless container

Step 3: Running Your First Container

Podman uses the same image format as Docker (OCI), so you can pull Docker-compatible images.

1. Pull an Image

Let’s pull the official Alpine Linux image:

podman pull alpine

Check your images:

podman images

2. Run a Container

Run an interactive container:

podman run -it alpine /bin/sh

Now you’re inside a running Alpine container. Try commands like:

apk add curl
curl https://archlinux.org

Exit the container with:

exit

3. List Containers

To list running containers:

podman ps

To list all containers (including exited ones):

podman ps -a

Step 4: Podman vs Docker Commands

Most Docker commands work the same way with Podman. Here are some equivalents:

Docker CommandPodman Command
docker pull nginxpodman pull nginx
docker run -d nginxpodman run -d nginx
docker pspodman ps
docker stop <id>podman stop <id>
docker rm <id>podman rm <id>
docker rmi <image>podman rmi <image>
docker build .podman build .

If you want full Docker compatibility, you can create an alias:

alias docker=podman

Add it to your shell profile (e.g., ~/.bashrc or ~/.zshrc).


Step 5: Working with Containers and Images

Building an Image

Podman supports building images from Dockerfiles:

podman build -t my-alpine-app .

Make sure your current directory has a valid Dockerfile.

Inspecting Containers

Use inspect to see detailed info about a container:

podman inspect <container-id>

You can use jq for pretty output:

podman inspect <id> | jq

Committing Changes to a New Image

You can save the current state of a container:

podman commit <container-id> my-custom-image

Step 6: Managing Pods

Unlike Docker, Podman includes first-class support for pods (like Kubernetes):

Creating a Pod

podman pod create --name mypod

Adding a Container to a Pod

podman run -dt --pod mypod alpine sleep 300

Listing Pods

podman pod ps

Viewing Containers in a Pod

podman ps --pod

Step 7: Podman and Systemd Integration

Podman can generate systemd unit files to manage containers as services.

Generate Systemd Unit

podman generate systemd --name mycontainer --files

This creates a .service file for systemd in the current directory.

Install and Enable the Unit

mkdir -p ~/.config/systemd/user
mv container-mycontainer.service ~/.config/systemd/user/
systemctl --user daemon-reexec
systemctl --user enable --now container-mycontainer.service

Check status:

systemctl --user status container-mycontainer

Step 8: Podman Compose (Optional)

To use Docker Compose-like functionality, install podman-compose:

sudo pacman -S podman-compose

Then you can use it just like Docker Compose:

podman-compose up

Note: podman-compose is less mature than Docker Compose but works for basic setups.


Step 9: Security Benefits of Rootless Containers

Running containers as non-root provides several security advantages:

  • Isolated namespaces: Your containers can’t affect the host system.
  • Limited damage: Even if a container is compromised, it can’t access root privileges.
  • Complies with user-level restrictions: Easier to manage in multi-user environments.

Conclusion

Podman is a robust, secure, and flexible container engine that’s particularly well-suited for Linux users who want to avoid the Docker daemon model. On Arch Linux, installing and using Podman is both seamless and rewarding. Whether you’re managing single containers, building images, or orchestrating pods, Podman gives you a powerful toolbox for containerized development.

Key Takeaways

  • Podman can replace Docker in most workflows with minimal changes.
  • Rootless container execution enhances system security.
  • Podman supports systemd integration and Kubernetes-style pods.
  • The Arch Linux ecosystem makes Podman easily accessible and up-to-date.

By understanding the fundamentals and commands covered here, you’re well on your way to managing containers effectively with Podman on Arch Linux.