Skip to content

Podman

Podman Compose tool allows you to define and manage multi-container applications using a compose.yaml file. It’s built on top of Podman, a daemonless container engine that provides rootless containers for enhanced security. Unlike Docker Compose, Podman Compose does not rely on a central daemon, making it more lightweight and secure. Podman Compose is compatible with Docker Compose files: you can use your existing compose.yaml files with minor changes.

Terminal window
sudo apt install podman podman-compose

Add default search registry by editing the registries file:

Terminal window
sudo nano /etc/containers/registries.conf

At the bottom of the file, add the following lines:

/etc/containers/registries.conf
[registries.search]
registries = ['docker.io', 'quay.io']

You could also append 'docker.io to compose’s image parameter to avoid this setting.

You can start containers on boot using Quadlet: I suggest you to use Podman Quadlets with Podman Desktop

It is quite instable.

Podlet GitHub repository

Terminal window
sudo apt install cargo
cargo install podlet

If the installation completes succesfully, you should get an output like this:

Finished `release` profile [optimized] target(s) in 4m 49s
Installing /home/pit/.cargo/bin/podlet
Installed package `podlet v0.3.0` (executable `podlet`)
warning: be sure to add `/home/pit/.cargo/bin` to your PATH to be able to run the installed binaries

Append to your configuration file (~/.bashrc or ~/.zshrc) the following line:

export PATH=/home/$USER/.cargo/bin:$PATH

Create .container file based on compose.yaml file:

Terminal window
cd your-project
# build the Dockerfile separately
podman build -t pit-blog . -f Dockerfile.node
podlet compose compose.yaml

You’ll get as output a file like:

node.container
[Container]
ContainerName=pit-blog
Image=docker.io/node:latest
Network=default
PublishPort=1111:4321
Volume=.:/usr/src/app
Volume=/usr/src/app/node_modules
[Service]
Restart=always
---
# default.network
[Network]
Driver=bridge

As you can see, it is giving two different files: node.container and default.network.

You should keep your network settings into a different file because systemd unit files don’t support a [Network] section.

You can take inspiration from those files to craete your own.

In in the case of an Astro.js blog based on Node, you can move into /home/$USER/.config/containers/systemd/ and create the following files:

pit-blog.container
Unit]
Description=Pit Blog - Astro js
[Install]
WantedBy=default.target
[Container]
ContainerName=pit-blog
Image=localhost/pit-blog
Network=default
PublishPort=1111:4321
Volume=%h/pietropoluzzi:/usr/src/app
Volume=%h/pietropoluzzi/node_modules:/usr/src/app/node_modules
[Service]
Restart=always

And the network file:

default.network
[Network]
Driver=bridge

Then enable the container to run as a systemctl service:

Terminal window
systemctl --user daemon-reload
systemctl --user status pit-blog.service
# if you cannot the service up and running, reboot
sudo reboot

TL;DN

  1. move into the project root: cd your-project
  2. build the Dockerfile separately: podman build -t pit-blog . -f Dockerfile.node
  3. get the podlet-generated files: podlet compose compose.yaml
  4. make some minor changes, then create .container and .network files
  5. reboot the system