Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Rootless containers with Podman: The basics

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

    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

    • Red Hat Enterprise Linux 10.2 and 9.8: Top features for developers

    • What GPU kernels mean for your distributed inference

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.