---
title: "How to Install and Use Podman (Docker Alternative)"
description: "Learn how to use Podman as a Docker alternative in creating and managing images and containers in this tutorial!"
canonical: "https://adamtheautomator.com/podman/"
---

# How to Install and Use Podman (Docker Alternative)

> Learn how to use Podman as a Docker alternative in creating and managing images and containers in this tutorial!

Source: https://adamtheautomator.com/podman/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Install and Use Podman (Docker Alternative)](https://adamtheautomator.com/wp-content/uploads/2022/03/How-to-Install-and-Use-Podman-Docker-Alternative.jpg)

# How to Install and Use Podman (Docker Alternative)

[![](https://secure.gravatar.com/avatar/2788bb1a3f735603f81eca51d68daec56a9d97e805a10268fb2c20afcc76b81b?s=192&d=mm&r=g)Nicholas Xuan Nguyen](https://adamtheautomator.com/author/nicholas-xuan-nguyen/)9 March 20227 min. read

Categories: [DevOps](/category/devops/)

Tags:[Command Line](/tag/command-line/)[Linux](/tag/linux/)[Podman](/tag/podman/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing Podman on Ubuntu](#installing-podman-on-ubuntu)
*   [Enabling OCI Registries](#enabling-oci-registries)
*   [Running Podman Containers with Podman Privileges](#running-podman-containers-with-podman-privileges)
*   [Working with Podman Images and Containers](#working-with-podman-images-and-containers)
*   [Conclusion](#conclusion)

Have you ever used [Docker](https://docker.io/) but found it to be too resource-intensive on your system? If so, you might want to check out [Podman](https://podman.io/), a new tool from Red Hat that provides an alternative to Docker.

Podman is a tool designed to make creating and managing containers seamless. And in this tutorial, you’ll install Podman and learn some basic usage scenarios. In the end, you’ll get to decide if Podman is the right tool for you.

Ready? Read on and start managing containers anew!

## **Prerequisites**

This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have the following.

*   A Linux machine – This demo uses Ubuntu 20.04 LTS, but any Linux distributions will work.

Related:[How to Install Ubuntu 20.04 LTS](https://adamtheautomator.com/install-ubuntu/)

*   A [non-root user with sudo privileges](https://www.liquidweb.com/kb/how-to-set-up-and-manage-sudo-permissions/).

## **Installing Podman on Ubuntu**

Before managing containers with Podman, you’ll first have to install Podman on your machine as it doesn’t come pre-installed in your Linux distribution.

To install Podman on Ubuntu, you’ll start by updating your APT package manager and adding the Podman package repository.

1\. Open your terminal, and run the [`apt update`](https://linuxize.com/post/how-to-use-apt-command/#updating-package-index-apt-update) command below to ensure you install the latest updates. This command ensures no package mismatches between your machine and the package repository.

```bash
sudo apt update -y
```

![Updating your Ubuntu system](https://adamtheautomator.com/wp-content/uploads/2022/03/image-95.png)

Updating your Ubuntu system

2\. Once you’ve updated your package index, run the `source` command below to run the `/etc/os-release` file as a script. This command ensures that your machine will recognize what version of Ubuntu you are using.

The os-release file contains operating system information, such as name and codename. The file also might include other details like version numbers of various components (kernel, X server, and so on.)

```bash
source /etc/os-release
```

![Identifying System Version](https://adamtheautomator.com/wp-content/uploads/2022/03/image-96.png)

Identifying System Version

3\. Run the `sh -c echo` command below to add the `kubic` deb package repository to APT. Podman is not available in Ubuntu’s default repositories, so you will need to add the Podman repository before installing it.

The command below performs the following:

*   Creates a new file (`sh -c`) in the `/etc/apt/sources.list.d/` directory. This directory is where APT downloads deb packages for installation on your machine.
    
*   Ensures that you’re using a specific version of Ubuntu (`{VERSION_ID}`), which is the version you previously got from the `source` command above in step two.
    
*   Redirects output (`>`) to write at the bottom of the file, ensuring that your input is written into the file correctly (`sources.list.d/devel:kubic:libcontainers:stable.list`).
    

```bash
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
```

![Adding the kubic deb package repository](https://adamtheautomator.com/wp-content/uploads/2022/03/image-97.png)

Adding the kubic deb package repository

4\. Now, run the `wget` command below to add the repository key to APT’s list of trusted keys.

Red Hat hosts the key, and they sign it with a private key that only verifies to other people who have their public key. This key ensures that Red Hat and not someone else releases the packages you download and install.

```bash
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | sudo apt-key add -
```

![Adding the repository key to APT's list of trusted keys](https://adamtheautomator.com/wp-content/uploads/2022/03/image-98.png)

Adding the repository key to APT’s list of trusted keys

Related:[How to Download Files with Python Wget](https://adamtheautomator.com/python-wget/)

5\. Rerun the `apt update` command to ensure APT’s list of packages is up to date.

```bash
sudo apt update -y
```

![Updating the APT's list of packages](https://adamtheautomator.com/wp-content/uploads/2022/03/image-99.png)

Updating the APT’s list of packages

6\. Next, run the [`apt install`](https://linuxize.com/post/how-to-use-apt-command/#installing-packages-apt-install) command below to install `podman`.

```bash
sudo apt install podman -y
```

![installing Podman](https://adamtheautomator.com/wp-content/uploads/2022/03/image-100.png)

installing Podman

7\. Finally, run the below command to check Podman’s installed `--version`.

```bash
podman --version
```

As you can see below, the Podman version installed is 3.4.2, the latest version at the time of writing, and yours may be different.

![Checking Podman version installed](https://adamtheautomator.com/wp-content/uploads/2022/03/image-101.png)

Checking Podman version installed

You can also run the podman inf command below to see more information about your Podman installation.

```basic
podman info
```

![Checking more information about Podman](https://adamtheautomator.com/wp-content/uploads/2022/03/image-102.png)

Checking more information about Podman

## **Enabling OCI Registries**

Before using Podman to create containers, ensure Podman can communicate with the [OCI](https://enabling-cloud.github.io/oci-learning/manual/OCIRegistry.html) registries. Podman supports multiple OCI registries simultaneously so that you can create containers using different repositories.

Open the `/etc/containers/registries.conf` file with your text editor of choice. This file defines all the registries that Podman can communicate with. Podman consults this file to find out which registries it should connect to.

```bash
sudo nano /etc/containers/registries.conf
```

Now, populate the _registries.conf_ file with the following lines, save the changes and close the editor.

These lines configure Podman to use the public registry on Docker Hub **([docker.io](http://docker.io/), [registry.access.redhat.com](http://registry.access.redhat.com/)**) and the private registry([**quay.io**](http://quay.io/)), which is recommended.

```bash
[[registry]]
prefix="[quay.io](<http://quay.io/>)"
location="internal.registry.mirror/quay"
[[registry]]
prefix="[docker.io](<http://docker.io/>)"
location="internal.registry.mirror/docker"
[[registry]]
prefix="[registry.access.redhat.com](<http://registry.access.redhat.com/>)"
location="internal.registry.mirror/redhat"
```

![Configuring Registries (registries.conf)](https://adamtheautomator.com/wp-content/uploads/2022/03/image-103.png)

Configuring Registries (_registries.conf_)

## Running **Podman Containers** **with Podman Privileges**

Now that you’ve installed Podman and configured the registries, you can start running Podman containers with Podman privileges. The Linux kernel supports a wide range of permission checks on its system calls, such as [capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html).

In the case of Podman containers, capabilities control the default behavior of root within the user namespace. You can use the `--privileged` flag when running a container to add all capabilities not already present in the container.

1\. Run the [`podman run`](https://docs.podman.io/en/latest/markdown/podman-run.1.html) command below to create a `fedora` container without capabilities.

```bash
podman run -d fedora sleep 100
```

![Creating a fedora container](https://adamtheautomator.com/wp-content/uploads/2022/03/image-104.png)

Creating a fedora container

2\. Next, run the below [`podman top`](https://docs.podman.io/en/latest/markdown/podman-top.1.html) command to list all the capabilities.

```bash
podman top -l capeff 
```

As shown below, the regular rootless container has limited capabilities.

![Listing all the capabilities](https://adamtheautomator.com/wp-content/uploads/2022/03/image-105.png)

Listing all the capabilities

3\. Run the `podman run` command below to create a container with all capabilities ([`--privileged`](https://www.youtube.com/watch?t=407&v=_w6H5yAbGj8&feature=youtu.be)).

```bash
podman run --privileged -d fedora sleep 100
```

4\. Lastly, rerun the `podman top` command to check the difference in capabilities.

```bash
podman top -l capeff
```

You’ll notice that full capabilities are available to this container because of the –privileged flag, as shown below.

You’ll notice that full capabilities are available to this container because of the –privileged flag, as shown The –privileged flag allows the container to run with all capabilities, not just those already in the container. This flag is important as it maps the container’s user namespace to the host’s namespace, giving it all the capabilities of processes running on your system.

![Checking the difference in permissions](https://adamtheautomator.com/wp-content/uploads/2022/03/image-106.png)

Checking the difference in permissions

> _If you don’t set the –privileged flag when launching a container, then the container will have a restricted set of capabilities. In the case of containers that use their own user namespace, you will have to give them all capabilities explicitly._

## **Working with Podman Images and Containers**

Now that you have learned how to add OCI Registries and capabilities for a container, you can work with Podman images and containers. For this demo, you’ll use NGINX for an image to create a container.

1\. Run the [`podman search`](https://docs.podman.io/en/latest/markdown/podman-search.1.html) command below to list all of the available Podman images for `nginx`

```bash
podman search nginx
```

Below, you can see that you get all of the available tagged images for NGINX from the _docker.io_, _quay.io_, and _redhat.com_ repo you added earlier in the “Enabling OCI Registries” section:

*   The **INDEX** column shows where the images are located.
    
*   The **OFFICIAL** column with **OK** status indicates the image in the row is created and supported by its official company. For example, the **NGINX** image with **OK** status is created and supported by its company, [NGINX](https://www.nginx.com/). These images will be updated as soon as security vulnerabilities and patch updates come out.
    
*   The **AUTOMATED** column with the **OK** status means that the images are automated builds. These images will be updated as soon as security vulnerabilities and patch updates come out.
    

![Listing all available Podman images for NGINX](https://adamtheautomator.com/wp-content/uploads/2022/03/image-107.png)

Listing all available Podman images for NGINX

2\. After picking an NGINX image to use, run the `podman` command below to download (`pull`) the image to your local machine.

This demo uses the nginx:alpine since it’s the smallest image and can run on memory only, saving time on the build steps later on.

```bash
podman pull nginx:alpine
```

At this point, you have a new image you can use to create a container with or use as a base image for other containers.

![Downloading the NGINX image](https://adamtheautomator.com/wp-content/uploads/2022/03/image-108.png)

Downloading the NGINX image

3\. Run the [`podman images`](https://docs.podman.io/en/latest/markdown/podman-image.1.html) command to see your new image’s information

```bash
podman images
```

![Listing all images](https://adamtheautomator.com/wp-content/uploads/2022/03/image-109.png)

Listing all images

4\. Now, execute the `podman run` command below to create a container from the image (`nginx:alpine`) and run an `nginx` server on that image.

This command performs the following:

*   Starts the container interactively (`-it`) and enables you to attach a terminal.
    
*   Deletes (`--rm`) the container after it exits/stops.
    
*   Runs the container in the background (`--d`) and publishes (`-p`) port `80` on all interfaces to port `8080` on the container.
    
*   Specify the name of the container (`--name web`).
    

```bash
podman run -it --rm -d -p 8080:80 --name web nginx:alpine
```

You will get a random container ID, as shown below, which you can use to monitor/start/stop/remove the container. Note down the container ID as it comes in handy when checking logs or stopping a specific container.

![Running the Container (web)](https://adamtheautomator.com/wp-content/uploads/2022/03/image-110.png)

Running the Container (web)

5\. Run the below [`podman ps`](http://%3Chttps://docs.podman.io/en/latest/markdown/podman-ps.1.html) command (without arguments) to check if your container is running.

```bash
podman ps
```

You can see that the web container is Up and uses port 8080/TCP on your host machine to expose its resource.

![Checking if the (web) Container is Running](https://adamtheautomator.com/wp-content/uploads/2022/03/image-111.png)

Checking if the (web) Container is Running

6\. For double-checking, open your web browser and navigate to **localhost:8080** or **your-server-ip:8080**, where **your-server-ip** is your server’s IP address.

If your container works, you’ll see the default NGINX welcome screen, as shown below.

![Viewing the default NGINX welcome screen](https://adamtheautomator.com/wp-content/uploads/2022/03/image-112.png)

Viewing the default NGINX welcome screen

If you are not sure how the container is set up, or if it has any errors, run the podman logs command below to get the log files for the container. Replace mycontainer with your target container ID.

```bash
podman logs mycontainer
```

![Checking log files for the (web) container](https://adamtheautomator.com/wp-content/uploads/2022/03/image-113.png)

Checking log files for the (web) container

7\. Run either of the [`podman stop`](https://docs.podman.io/en/latest/markdown/podman-stop.1.html) commands below to stop your container. Replace `mycontainer` with your target container ID, or replace `web` with the actual container name.

Since you used the –rm flag in step four, Podman deletes your container as soon as you stop that container. This setup helps keep your workspace clutter-free.

```bash
# Stops the container by Container ID
podman stop mycontainer
# Stops the container by Container Name
podman stop web
```

![Stopping a container](https://adamtheautomator.com/wp-content/uploads/2022/03/image-114.png)

Stopping a container

8\. Finally, run the [`podman ps`](https://docs.podman.io/en/latest/markdown/podman-ps.1.html) command to list all containers, including a stopped container.

```bash
podman ps -a
```

Your container got deleted when you previously stopped it, so you won’t get anything on the list, as shown below.

![Checking the stopped container](https://adamtheautomator.com/wp-content/uploads/2022/03/image-115.png)

Checking the stopped container

## Conclusion

Throughout this article, you’ve learned to install Podman and how to work with images and containers for deployments. At this point, you can now use the OCI-enabled images from _[docker.io](http://docker.io)_, _[quay.io](http://quay.io)_, and _[redhat.com](http://redhat.com)_ repositories to create your own containers.

With this newfound knowledge, why not [build your Kubernetes pods with Podman play kube](https://www.redhat.com/sysadmin/podman-play-kube-updates), or start [using Ansible to automate Podman containers](https://redhatnordicssa.github.io/ansible-podman-containers-1)?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpodman%2F&text=How%20to%20Install%20and%20Use%20Podman%20\(Docker%20Alternative\))[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpodman%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpodman%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/07/How-to-Install-Eclipse-IDE-on-Linux.jpg)

### [How to Install Eclipse IDE on Linux](/how-to-install-eclipse/)

Learn the ins-and-outs of how to install Eclipse on Linux to take advantage of this powerful IDE in this ATA Learning tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2023/11/automating-tasks.jpg)

### [Automating Tasks Using Bash Scripts and Cron Jobs with AWS](/automating-tasks/)

Discover how to combine bash scripts with cron jobs and leverage the power of AWS for automating tasks in this ATA Learning tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2023/02/kubeadm.jpg)

### [How to Get Started Building Kubernetes Clusters with kubeadm](/kubeadm/)

Learn how to create and manage Kubernetes clusters with the kubeadm command-line tool in this tutorial by ATA Learning!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
