Podman Basics 07: Using Multi-Container Applications

Podman-compose is a script that simplifies the use of Podman to manage multi-container setups. It interprets the docker-compose.yml file and creates a Podman-compatible setup. This means you can use your existing Docker Compose files with Podman, making the transition smoother if you’re moving from Docker to Podman.

Before diving into the usage of podman-compose, it’s essential to have it installed on your system. The installation process varies depending on the Linux distribution you are using. For instance, on Ubuntu 22.10 and later, as well as Debian 12 and later, you can install it using the apt package manager. On Rocky Linux you can install podman-compose with using the Python PIP.

Using podman-compose

Podman-compose is compatible with Docker Compose, for example if you want to install a Drupal server using a Postgresql external database, you need two containers. Let’s create a very simple compose file!

version: '3.1'

services:

  drupal:
    image: docker.io/library/drupal:10-apache
    ports:
      - 8080:80
    volumes:
      - /var/www/html/modules
      - /var/www/html/profiles
      - /var/www/html/themes
      - /var/www/html/sites
    netowrk: n_drupal

  postgres:
    image: docker.io/library/postgres:16
    environment:
      POSTGRES_PASSWORD: secretpwforthedb
    network: n_drupal

Starting containers

To start all containers defined in your docker-compose.yml file, you would use the up command. This command creates and starts the services described in the file, setting up the necessary networks, volumes, and other resources as defined.

podman-compose up -d

I noticed that the network management is faulty with the script, thus the Podman network must be created beforehand with the podman network create command.

Stopping containers

To stop all running containers that were started with podman-compose, you can use the down command. This will stop and remove the containers, networks, and volumes created by the up command.

podman-compose down

The command stops and removes the containers.

Pulling images

With the pull command, podman-compose can download all necessary images at once, ensuring that your containers are running the latest versions of the images specified in your compose file.

podman-compose pull

Custom compose files

If you wish to use a different name for your compose file, podman-compose provides the flexibility to specify the file you want to use, allowing for multiple compose files for different environments or configurations.

The benefits of podman-compose

Podman-compose brings several advantages to the table:

  • Compatibility: It follows the Compose specification, ensuring compatibility with your existing Docker Compose files.
  • Security: Podman’s daemonless architecture means that there’s no long-running background process that requires root privileges, enhancing the security of your system.
  • Ease of use: Podman-compose simplifies the management of multi-container environments, making it accessible for beginners and efficient for experienced users.

If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES

Now we have an IRC channel as well: irc.libera.chat / #tomsitcafe

Leave a comment