Podman - Getting Started

Podman is a daemonless container engine to manage, run and develop OCI Containers on your Linux System. It supports rootfull and rootless mode for your containers and brings some features, which are not present in Docker.

Podman - Getting Started

Podman is a daemonless container engine to manage, run and develop OCI Containers on your Linux System. It supports rootfull and rootless mode for your containers and brings some features, which are not present in Docker.

If you don't have any idea what containers are about, you can check out this article.

Features

Daemonless

Podman runs containers without a central daemon. There is no central service, that may crash or needs to be restarted. Instead, you will see one or more processes started per container.

Rootless

Podman supports rootless and rootfull deployments. This means, that you can run a container without a special docker group as a regular user and deploy containers. This adds some additional comfort and security to your development and deployment workflows.

Systemd ready

Podman is built with systemd in mind. This means, Podman can be controlled via system units and is also supporting systemd in containers, out of the box.

Docker compatible

If you are using docker at the moment, you can easily switch your workflows. Almost everything is already working for usual workflows. You can simply put an alias (alias docker=podman) in your .bashrc and everything should work as before.

Ansible in mind

The Podman development does not stop at a container engine. There is currently a lot of development happening to use the power of Ansible. You can find the ansible-collection at GitHub.

Hint
The guide is tested on Fedora 33 with Podman 2.2.1.

Installation

Podman is supported on a wide variety of Linux distributions. For this blog article, I will focus on Fedora and CentOS. You can find installation guides for many other Linux derivates here.

Fedora 31+

In most Fedora installations, Podman is already there. If this is not the case for you, you can install it with the below commands.

# Install
$ sudo dnf install podman

# Check Version
$ podman -v
podman version 2.2.1

# Run a test container
$ podman run --rm busybox echo "hello world"

CentOS 8+

Podman is also available for CentOS. The version is slightly older, but you can also install the current version. Below you will find the commands to install it.

# Install
$ sudo dnf install podman

# Check Version
$ podman -v
podman version 2.2.1

# Run a test container
$ podman run --rm busybox echo "hello world"

For the more current version, please check out the installation guide for CentOS, using the Kubic project.

Rootless container

As already stated, Podman supports rootless containers. Running a web server is one of the first things one can do to see how containers work. Podman can do this without root privileges (sudo or docker group).

# Start a container
$ podman container run -d --name web01 -P docker.io/library/httpd:latest

This command started (run) a container in the background (detached, -d), with the name web01 (--name web01) and published all exposed ports (-P). The image used is docker.io/library/httpd:latest.

# Check if the container runs
$ podman container ls
CONTAINER ID  IMAGE                           COMMAND           CREATED        STATUS            PORTS                  NAMES
6769b9b7d6dd  docker.io/library/httpd:latest  httpd-foreground  6 seconds ago  Up 6 seconds ago  0.0.0.0:35723->80/tcp  web01

You can see a container running and also see the automatically assigned ports for it. Podman will handle all exposed ports automatically and assign some high ports to it.

# Check the website, provided from the container
$ curl localhost:35723

You can also open your browser and point it towards localhost:35723 to see the website.

Rootfull container

For a rootfull deployment, you can do exactly the same commands as above, but you need to prefix them with sudo.

# Start a container
$ sudo podman container run -d --name web01 -P docker.io/library/httpd:latest

# Check if the container runs
$ sudo podman container ls
CONTAINER ID  IMAGE                           COMMAND           CREATED      STATUS          PORTS                  NAMES
5be35412fa8e  docker.io/library/httpd:latest  httpd-foreground  5 hours ago  Up 5 hours ago  0.0.0.0:44557->80/tcp  web01

# Check the website, provided from the container
$ curl localhost:44557

Documentation

The documentation for Podman is currently not as exhaustive as for docker, but the developers are heavily working on it. For now, you can check these sources for guides, tutorials and documentation:

Conclusion

With Podman, you are having a very modern and easy to use Docker replacement. I will ensure to provide more guides in the future and ensure, you will be up-to-date.

I am also using Podman for all services at while-true-do.io.