Website Vidya
Linux & ServersStep-by-Step Guide

How to Install Podman on Ubuntu: Rootless Container Alternative to Docker

Learn how to install podman on ubuntu rootless with subuid/subgid user mapping, container registries, podman compose, and systemd service generation.

RR
Rajesh RayLead Systems Educator
Published:
5 min read
PDF Cheat Sheet
How to Install Podman on Ubuntu: Rootless Container Alternative to Docker
AI Executive SummaryWebsiteVidya AI

5 min read

Learn how to install podman on ubuntu rootless with subuid/subgid user mapping, container registries, podman compose, and systemd service generation.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Installing Podman and Container Utilities
  • Step 2: Configuring Rootless User SubUID and SubGID Mappings
Grounded in full engineering runbookWebsiteVidya AI Engine

Containerization is a foundational pillar of modern software engineering, traditionally dominated by Docker.

However, traditional Docker architectures rely on a monolithic background daemon (dockerd) that runs with full root privileges on the host system.

Podman (Pod Manager) is a daemonless, open-source container engine designed specifically to run OCI-compliant containers and pods rootlessly out of the box.

Because rootless Podman maps unprivileged host user IDs to root inside container namespaces, any security vulnerability inside a container is contained without compromising the underlying host.

Advertisement

In this guide, we walk through how to install podman on ubuntu rootless, configure user namespace mappings, pull container images, and generate systemd service units.

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

Advertisement
  • A server or workstation running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
  • A standard unprivileged user account with sudo access for initial installation.
  • Access to a bash terminal shell.
  • Basic understanding of container concepts (images, ports, volumes).

Step 1: Installing Podman and Container Utilities

Ubuntu 24.04 LTS includes Podman natively in the official software repositories.

Along with the core podman binary, install podman-compose and complementary tools:

Refresh package lists and install Podman using apt:

# Update package indexes:
sudo apt update

# Install Podman and container tools:
sudo apt install -y podman podman-compose

# Verify installed Podman version:
podman --version
# Output: podman version 4.9.3

Step 2: Configuring Rootless User SubUID and SubGID Mappings

Rootless Podman relies on user namespaces provided by the Linux kernel to map unprivileged host user IDs to container IDs.

Advertisement

The system manages these ranges through two configuration files: /etc/subuid and /etc/subgid.

Verify that your user account has an assigned range of subordinate UIDs and GIDs (typically 65,536 IDs):

# Check subordinate UID allocation for your user (e.g. sysadmin):
grep "sysadmin" /etc/subuid
# Output: sysadmin:100000:65536

# Check subordinate GID allocation:
grep "sysadmin" /etc/subgid
# Output: sysadmin:100000:65536

# If missing, add them manually:
sudo usermod --add-subuids 100000-165535 sysadmin
sudo usermod --add-subgids 100000-165535 sysadmin

Enabling Systemd User Lingering

By default, background processes launched by unprivileged users terminate when the user logs out of their terminal session.

To ensure that rootless Podman containers continue running persistently across reboots and logouts, enable user lingering with loginctl:

# Enable systemd lingering for active user:
loginctl enable-linger $USER

# Verify lingering status:
loginctl show-user $USER | grep Linger
# Output: Linger=yes

Step 3: Running Your First Rootless Container

Because Podman is CLI-compatible with Docker, virtually all Docker commands work seamlessly with Podman.

Run a test Nginx web server container as your regular unprivileged user (without sudo):

Note that rootless containers cannot bind to privileged ports below 1024 by default, so bind to port 8080:

# Run rootless Nginx container on port 8080 (NO sudo!):
podman run -d --name webserver -p 8080:80 docker.io/library/nginx:alpine

# List running containers:
podman ps

# Output:
# CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS        PORTS                 NAMES
# 3f8a1c9b2e4d  docker.io/library/nginx:alpine  nginx -g daemon o...  5 seconds ago  Up 5 seconds  0.0.0.0:8080->80/tcp  webserver

# Test connection via curl:
curl -I http://localhost:8080
# HTTP/1.1 200 OK

Step 4: Generating Systemd Service Units for Containers

One of Podman's most powerful native features is integrating directly with systemd.

Podman can automatically generate systemd service unit files that manage container lifecycles, healthchecks, and auto-restarts upon boot.

Generate and enable a systemd service unit for your rootless container:

# Create local user systemd unit directory:
mkdir -p ~/.config/systemd/user/

# Generate unit file from running container:
podman generate systemd --new --files --name webserver

# Move generated unit file:
mv container-webserver.service ~/.config/systemd/user/

# Reload user systemd daemon and enable service:
systemctl --user daemon-reload
systemctl --user enable --now container-webserver.service

Rootless Pods: Grouping Multiple Containers Together

Unlike Docker which focuses purely on individual containers, Podman natively implements the Kubernetes concept of a Pod.

A pod is a group of one or more containers that share the same network namespace, IP address, and port bindings.

Containers within the same pod communicate with each other over localhost with ultra-low latency:

# Create a rootless pod exposing port 8080:
podman pod create --name web-pod -p 8080:80

# Launch an Nginx web server inside the pod:
podman run -d --pod web-pod --name proxy-app docker.io/library/nginx:alpine

# Inspect the pod and its constituent containers:
podman pod ps
podman ps --pod

Building Container Images with podman build

Podman replaces docker build directly using standard Dockerfile or Containerfile syntax.

You can build OCI-compliant container images rootlessly without running a daemon:

Build images and push to external registries such as GitHub Packages or Quay.io:

# Build an image from a local Containerfile or Dockerfile:
podman build -t my-custom-app:latest .

# Inspect local image repository:
podman images

Managing Storage and Cleaning Unused Containers

Because rootless containers store images and layers in user home directories (~/.local/share/containers/storage/), disk space management is crucial on multi-tenant servers.

Podman provides powerful disk analysis and cleanup subcommands:

Prune stopped containers, dangling build layers, and unused networks to reclaim filesystem space:

# Inspect disk space consumed by rootless containers and images:
podman system df

# Reclaim space by pruning all unused container resources:
podman system prune -a --volumes -f

Configuring Volume Bind Mounts and Permission Flags

When mounting directories from the host filesystem into rootless containers, Linux permission boundaries and mandatory access controls must be respected.

Podman supports appending the :Z flag to volume options, which automatically relabels the target directory with private container context:

This ensures the unprivileged container process has write access to host directory mounts without altering host ownership:

# Run container with private relabeled volume mount:
podman run -d --name app-service -v ~/app-data:/data:Z -p 8080:80 nginx:alpine

# Inspect active volume mounts:
podman inspect app-service --format '{{.Mounts}}'

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Error: cannot setup namespace using newuidmap: exit status 1

Cause: Missing subuid or subgid mappings for the active user account.

Resolution: Configure subuid and subgid ranges using usermod --add-subuids.

sudo usermod --add-subuids 100000-165535 $USER && sudo usermod --add-subgids 100000-165535 $USER

Error: rootlessport: cannot bind to ports below 1024

Cause: Linux security policy prevents unprivileged users from binding to low-numbered privileged ports.

Resolution: Bind containers to high ports (e.g. 8080 or 8443) or adjust net.ipv4.ip_unprivileged_port_start sysctl.

sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80

Security Best Practices and Hardening

Running containers rootlessly provides defense-in-depth: if an attacker escapes the container, they only acquire unprivileged host access.

Store persistent container volumes in your user's home directory with standard permissions.

Never run sudo podman unless you specifically require root-level networking or hardware device pass-through.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
Yes. You can install podman-compose or enable the Podman Docker-compatible socket (systemctl --user enable --now podman.socket) and use the standard Docker Compose CLI seamlessly.
No. Podman follows the traditional Unix fork-exec model: when you run a container, Podman directly launches the OCI runtime (crun or runc) without a persistent background service.
Yes. Because Podman supports identical CLI flags, you can add alias docker=podman to your ~/.bashrc file to transition existing workflows effortlessly.
Rootless Podman stores container images, layers, and volumes inside your user's home directory at ~/.local/share/containers/storage/.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout