Linux Format

Container engines to full pod power!

How to get down with the Podman and blast off with some containers.

-

DAMAGE LIMITATION “Because all applicatio­ns can be run by regular users without root, malicious applicatio­ns can’t break into important parts of the system.”

To non-Linuxy people, Podman is either the shady guy selling knock-off vape supplies outside your local youth club, or some kind of third-tier superhero with the power to control dolphins with his mind. An outside possibilit­y would be the frozen refugee from an intergalac­tic war, discovered in his icy refuge below Antarctica.

In the context of this magazine, however, Podman is none of these things. It is, in fact, the latest and greatest containeri­sation solution for Linux. All the cool kids are using it to develop and deploy transferab­le applicatio­ns on their systems, and you should, too. Originally developed by Red Hat, Podman is a container engine, and its containers are known, somewhat unsurprisi­ngly, as pods. Download a Podman applicatio­n, and you get one infraconta­iner, which maintains namespaces and manages everything, along with other containeri­sed applicatio­ns.

If you’re used to other container management systems, such as Docker, you’ll be used to occasional­ly running things using sudo, or interactin­g with rootowned daemons such as the Docker engine. While this is generally fine, allowing access to system processes can introduce all kinds of potential security nightmares to your system.

Podman doesn’t employ root-owned daemons, and a regular user can interact with, build and deploy images, and use containers without ever needing escalated privileges. It manages this by forking itself into a child process, which then becomes the container. Because all applicatio­ns can be run by regular users without root, malicious applicatio­ns can’t break into important parts of the system, and any damage is limited to the one user. It may suck to be that user, but at least you’re not having to disinfect your hard drive with bleach.

If you’re administer­ing a system used by other people, the rootless approach has the added benefit of letting users deploy software safely without dragging the admin out of bed, and without taking the easy, but insecure, option of adding them to the Docker group.

With Podman’s obvious advantages summarised, it’s time to actually install Podman on your system.

Fortunatel­y, this isn’t too much of a chore, because most recent distributi­ons contain Podman in their default repositori­es.

Open a terminal either by selecting it from your system menu or by hitting the appropriat­e key binding (usually Ctrl+Alt+T).

Update your system in the usual way. On Debianbase­d distros, enter:

$ sudo apt update && sudo apt upgrade -y

Now install Podman with:

$ sudo apt install podman

If you use Arch or its derivative­s, use:

$ sudo pacman -S podman

Or, for members of the Fedora family, enter:

$ sudo yum -y install podman

Installati­on should only take a few seconds depending on your connection speed. You can verify

Podman is installed with:

$ podman -v

That was easy.

Despite all of the behind-the-scenes wizardry that makes Podman a superior and more secure alternativ­e to Docker, the two orchestrat­ion tools both exist for the same purpose – managing containers – and both adhere to the Open Container Initiative (OCI). This open governance structure is responsibl­e for setting standards for the Runtime Specificat­ion, Image Specificat­ion and Distributi­on Specificat­ion of containers. In practice, this means that anything that was designed to run with Docker should also run with Podman and vice versa.

Even the commands used to manage your containers and images are virtually identical, so it’s relatively easy to swap your container orchestrat­ion over from Docker to the newer, cooler, rootless Podman instead.

Your very first Podman

PiGallery2 is a directory first image gallery for Linux that you access through a web browser. You can run it on your local machine, on a VPS or on a Raspberry Pi. It’s one of the simplest and most useful pieces of selfhosted software we’ve come across. If you have a directory of images, and want to be able to view them on your PC, on your network or remotely, PiGallery2

generates thumbnails, extracts metadata, shows maps of where the images were taken, and more.

It’s also super-lightweigh­t, and easy to deploy with Podman, making it the perfect candidate for this tutorial.

To start with, make a new directory for PiGallery2 to live in, then move into your new directory:

$ mkdir pigallery2 && cd pigallery2

Create new directorie­s for PiGallery2 to store configs, temporary files and database:

$ mkdir config db temp

In the following command, make sure you set the actual path for your images directory:

$ podman run -p 1400:80 -e NODE_ENV=production -v ~/pigallery2/config:/app/data/config -v ~/pigallery2/:/ app/data/db -v :/app/data/ images -v ~/pigallery2/:/app/data/tmp docker.io/ bpatrik/pigallery2:latest

One important way the above command differs from the official PiGallery2 documentat­ion is that by default, Podman doesn’t assume the images you want to download are located on Docker Hub.

While the GitHub docs merely state to pull the bpatrik/pigallery2:latest image, with Podman, you need to prefix the image name with docker.io. In this example, the complete image name is docker.io/ bpatrik/pigallery2:latest.

Another thing you need to take into account is that unlike Docker, Podman runs without root privileges. This means that some of the things you might like to do are not available to you out of the box. Eagle-eyed readers will note that we have specified port 1440 in our Podman command, rather than the more customary port 80. This is because 80 is a privileged port and, being rootless, Podman is unable to use this.

You can get around this by specifying a port number over 1024, as we did, or make port 80 unprivileg­ed with:

$ sudo echo ‘net.ipv4.ip_unprivileg­ed_port_

start=80’ >> /etc/sysctl.conf

This probably isn’t the best idea, though. When you hit Enter, Podman downloads the necessary images and sets up containers for PiGallery2. When it completes, feel free to close your terminal window.

Open a browser and enter: localhost:1400

to reach the admin page. Log in with username admin, and the password admin. Remember to change both of these before you expose your private photos to the internet.

By default, PiGallery2 shows your images in date ascending order. You can change this in Settings.

To control your containers, you need to know the container ID or name, so open a terminal and enter:

$ podman ps

The output lists container IDs, the image name, uptime, ports in use, and a supposedly friendly name. In our case, the name was beautiful_heyrovsky.

To bring your containers down, enter:

$ podman stop

 ?? ?? It may be 2023, but us old-timers still need a high-quality selfhosted gallery to quickly locate an appropriat­e reaction meme.
It may be 2023, but us old-timers still need a high-quality selfhosted gallery to quickly locate an appropriat­e reaction meme.
 ?? ??
 ?? ?? With a single command, you can pull and deploy container images easily. Granted, it’s a fairly long command, but still…
With a single command, you can pull and deploy container images easily. Granted, it’s a fairly long command, but still…
 ?? ??

Newspapers in English

Newspapers from Australia