Exploring Podman
Given my last post, you wouldn't be remiss to think I was in the process of building out a full Kubernetes cluster. However, as I was looking into setting up a VM cluster to use Talos Linux, it was still very clearly overkill.
When managing servers, there are 2 general approaches: either as 'cattle' or as 'pets'. While the 'cattle' method is preferable since servers can be easily swapped out, the reality is that since all of my servers have different physical capabilities, they are more easily managed as 'pets'. As a result, I have been diving deep into rootless Podman.
Note
This post will be from the perspective of setting up Podman on a server rather than on Podman Desktop
Poor Documentation
Coming from Docker, Podman's documentation is disappointing and inconsistent.
The documentation at https://docs.podman.io/en/latest/ is only filled out at the landing page and the Introduction, neither of which give a helpful overview beyond the bare necessity for starting a single container. Past that, the Commands section is just HTML renders of the manpages, and Tutorials literally point to Markdown files under a subdirectory in a Github repository (and Github is down again as of writing this).
The rootless documentation, which is probably Podman's biggest selling point, is a Markdown file that mostly covers edge cases instead of default setup and usage.
The Arch Wiki Podman documentation was a bit better especially regarding Quadlet configuration, but was also not helpful enough to get started.
In contrast, Docker's documentation is all available under: https://docs.docker.com.
- The full CLI reference can be found here: https://docs.docker.com/reference/cli/docker/
- Full Dockerfile configuration reference here: https://docs.docker.com/reference/dockerfile/
- And full Compose File reference here: https://docs.docker.com/reference/compose-file/
This post is, in part, an effort to teach myself how Podman works compared to Docker.
What is Podman?
Docker is pretty simple to understand conceptually. You enable & start the Docker daemon with systemd, and all Docker containers are managed by it. Podman skips a step: the container manager is systemd itself.
Docker uses Compose and YAML files to manage container deployments (compose.yaml). Podman uses systemd-style unit files to manage containers + their resources, and they are all collectively called Quadlets.
Podman is not a full-fledged daemon the way Docker is, but instead is a tool that can start processes as containers. You may be wondering: "what is the point of Podman if systemd is already doing all of the work?". The answer is that container creation and management is much more convenient to handle with the podman CLI tool rather than manually wiring up systemd units to each other.
An added bonus is that Podman was created with Kubernetes in mind (unlike Docker) which makes it easier to eventually deploy these workloads into clusters. However, this is more advanced and I won't be covering it here.
Rootless Setup
Since this is my first foray into Podman, this setup may have some blind spots. However, I have confirmed that basic usage works on a Fedora 44 server with SELinux's default targeted policy left in enforcing mode.
Installing is pretty simple:
sudo dnf install podman
By default, rootless configuration should work out-of-the-box for a modern Linux OS. Since RedHat is Podman's primary corporate backer, you will find best support for it on RHEL/Fedora installations.
I wanted to fully utilize a rootless Podman configuration, so I decided that a dedicated non-admin user without sudo access would be a solid security posture to run containers from.
sudo useradd podrunner --shell /usr/bin/zsh --create-home
The only way to get to this user is through an SSH key that was manually added through a regular admin account on the server.
sudo mkdir /home/podrunner/.ssh/
sudo vi /home/podrunner/.ssh/authorized_keys
sudo chown -R podrunner: /home/podrunner/.ssh/
sudo chmod -R u=rwX,go= /home/podrunner/.ssh/
sudo restorecon -Rv /home/podrunner/.ssh/
Before logging into the podrunner account, enable lingering so that containers can start & run without requiring you to log in first:
sudo loginctl enable-linger podrunner
Now, you can log into the account using SSH (after exiting the admin session). You cannot use sudo or su to become the podrunner account, since neither of those will start a login session.
ssh podrunner@fedoraWhat are Quadlets?
A Quadlet is any configuration file used to define a Podman resource. There are currently 7, but the most relevant ones for running containers are .container, .network, .pod and .volume.
The official documentation for them can be found in the terribly-named podman-systemd.unit(5) manpage. You can also find Quadlet-specific configuration with the exact same layout but more detailed descriptions for each key here:
There are also other Quadlet types (.build, .image, .kube), but unless you know you need them, they are likely not as important.
They all operate with the same basic pattern. The only required section is a Quadlet-specific section (eg., [Container], [Network], [Pod], [Volume]) and keys underneath in INI-style format. You can optionally specify common systemd-style unit file configurations to further flesh out the files, such as a Description= key underneath a [Unit] section to give your Quadlet a description.
'Installing' a Quadlet means placing it in a directory. For rootless Podman, this will normally be under ~/.config/containers/systemd/. Then, run:
systemctl --user daemon-reload
in order to make systemd turn all the Quadlets into .service files.
There are a number of other considerations to make, but this post is running long enough and they deserve a dedicated post.
Pods = Compose
When I deployed multi-container applications with Docker, I would build out a large Compose file to wire them all together into somewhat of a logical unit.
In Kubernetes parlance, a Pod is a logical grouping of containers. The name "Podman" isn't a coincidence, it stands for "Pod Manager" and was a fundamental approach for the tool.
While somewhat simplistic, these can be treated as generally similar concepts to achieve the same goal of grouping multiple containers into a logical unit.