Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Rootless containers with Podman: The basics

September 25, 2020
Prakhar Sethi
Related topics:
ContainersLinuxOpen source
Related products:
Red Hat OpenShift

Share:

    As a developer, you have probably heard a lot about containers. A container is a unit of software that provides a packaging mechanism that abstracts the code and all of its dependencies to make application builds fast and reliable. An easy way to experiment with containers is with the Pod Manager tool (Podman), which is a daemonless, open source, Linux-native tool that provides a command-line interface (CLI) similar to the docker container engine.

    In this article, I will explain the benefits of using containers and Podman, introduce rootless containers and why they are important, and then show you how to use rootless containers with Podman with an example. Before we dive into the implementation, let's review the basics.

    Why containers?

    Using containers isolates your applications from the various computing environments in which they run. They have become increasingly popular because they help developers focus on the application logic and its dependencies, which they bind in a single unit. Operations teams also like containers because they can focus on managing the application, including deployment, without bothering with details such as software versions and configuration.

    Containers virtualize at the operating system (OS) level. This makes them lightweight, unlike virtual machines, which virtualize at the hardware level. In a nutshell, here are the advantages of using containers:

    • Low hardware footprint
    • Environment isolation
    • Quick deployment
    • Multiple environment deployments
    • Reusability

    Why Podman?

    Using Podman makes it easy to find, run, build, share, and deploy applications using Open Container Initiative (OCI)-compatible containers and container images. Podman's advantages are as follows:

    • It is daemonless; it does not require a daemon, unlike docker.
    • It lets you control the layers of the container; sometimes, you want a single layer, and sometimes you need 12 layers.
    • It uses the fork/exec model for containers instead of the client/server model.
    • It lets you run containers as a non-root user, so you never have to give a user root permission on the host. This obviously differs from the client/server model, where you must open a socket to a privileged daemon running as root to launch a container.

    Why rootless containers?

    Rootless containers are containers that can be created, run, and managed by users without admin rights. Rootless containers have several advantages:

    • They add a new security layer; even if the container engine, runtime, or orchestrator is compromised, the attacker won't gain root privileges on the host.
    • They allow multiple unprivileged users to run containers on the same machine (this is especially advantageous in high-performance computing environments).
    • They allow for isolation inside of nested containers.

    To better understand these advantages, consider traditional resource management and scheduling systems. This type of system should be run by unprivileged users. From a security perspective, fewer privileges are better. With rootless containers, you can run a containerized process as any other process without needing to escalate any user's privileges. There is no daemon; Podman creates a child process.

    Example: Using rootless containers

    Let's get started using rootless containers with Podman. We'll start with the basic setup and configuration.

    System requirements

    We will need Red Hat Enterprise Linux (RHEL) 7.7 or greater for this implementation. Assuming you have that, we can begin configuring the example.

    Configuration

    First, install slirp4netns and Podman on your machine by entering the following command:

    $ yum install slirp4netns podman -y
    

    We will use slirp4netns to connect a network namespace to the internet in a completely rootless (or unprivileged) way.

    When the installation is done, increase the number of user namespaces. Use the following commands :

    $ echo “user.max_user_namespaces=28633” > /etc/sysctl.d/userns.conf 	 
    $ sysctl -p /etc/sysctl.d/userns.conf
    

    Next, create a new user account and name it. In this case, my user account is named Red Hat:

    $ useradd -c “Red Hat” redhat
    

    Use the following command to set the password for the new account (note that you must insert your own password):

    $ passwd redhat
    

    This user is now automatically configured to be able to use a rootless instance of Podman.

    Connect to the user

    Now, try running a Podman command as the user you've just created.  Do not use su - because that command doesn't set the correct environment variables. Instead, you can use any other command to connect to that user. Here's an example:

    $ ssh redhat@localhost
    

    Pull a Red Hat Enterprise Linux image

    After logging in, try pulling a RHEL image using the podman command (note that ubi stands for Universal Base Image):

    $ podman pull ubi7/ubi
    

    If you want more information about the image, run this command:

    $ podman run ubi7/ubi cat /etc/os-release
    

    To check the images that resulted from the above command, along with any other images on your system, run the command:

    $ podman images
    

    It is also possible for a rootless user to create a container from these images, but I'll save that for another article.

    Check the rootless configuration

    Finally, verify whether your rootless configuration is properly set up. Run the following command to show how the UIDs are assigned to the user namespace:

    $ podman unshare cat /proc/self/uid_map
    

    Conclusion

    This article demonstrated how to set up rootless containers with Podman. Here are some tips for working with rootless containers:

    • As a non-root container user, container images are stored under your home directory (for instance, $HOME/.local/share/containers/storage), instead of /var/lib/containers. This directory scheme ensures that you have enough storage for your home directory.
    • Users running rootless containers are given special permission to run on the host system using a range of user and group IDs. Otherwise, they have no root privileges to the operating system on the host.
    • A container running as root in a rootless account can turn on privileged features within its own namespace. But that doesn't provide any special privileges to access protected features on the host (beyond having extra UIDs and GIDs).

    Learn more about setting up rootless containers with Podman here.

    Last updated: April 1, 2022

    Recent Posts

    • Why some agentic AI developers are moving code from Python to Rust

    • Confidential VMs: The core of confidential containers

    • Benchmarking with GuideLLM in air-gapped OpenShift clusters

    • Run Qwen3-Next on vLLM with Red Hat AI: A step-by-step guide

    • How to implement observability with Python and Llama Stack

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue