Ubuntu 26.04

Podman : Use Compose2026/05/07

 

To Install Podman Compose, it's easy to configure and run multiple containers as a Podman application.

[1] Install Podman Compose.
root@dlp:~#
apt -y install podman-compose
[2] For example, Configure an application that has Web and DB services with Docker Compose.
# define Web service container

root@dlp:~#
vi Dockerfile
FROM ubuntu
LABEL Maintainer="ServerWorld <admin@srv.world>"

RUN apt-get update
RUN apt-get -y install nginx
RUN echo "Compose Test on Nginx" > /var/www/html/index.html

EXPOSE 80
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

# define application configuration

root@dlp:~#
vi docker-compose.yml
services:
  db:
    image: docker.io/library/mariadb
    volumes:
      - /var/lib/containers/disk01:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: ubuntu
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: ubuntu_db
    user: 0:0
    privileged: true
    ports:
      - "3306:3306"
  web:
    build: .
    ports:
      - "80:80"
    volumes:
      - /var/lib/containers/disk02:/usr/share/nginx/html
    privileged: true

# build and run

root@dlp:~#
podman-compose up -d

.....
.....
Writing manifest to image destination
157db0791556c452e6e893b8d273f149ebdd58f50f0ab5c398d33a85ffb6c544
e448c6fa76fd3cb664a2add2bea27c1c4748fa449322fdee6ebdf2ed7ac1bc98
root_db_1
root_web_1

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                             COMMAND               CREATED        STATUS        PORTS                   NAMES
157db0791556  docker.io/library/mariadb:latest  mariadbd              4 minutes ago  Up 4 minutes  0.0.0.0:3306->3306/tcp  root_db_1
e448c6fa76fd  localhost/root_web:latest         /usr/sbin/nginx -...  4 minutes ago  Up 4 minutes  0.0.0.0:80->80/tcp      root_web_1

# verify accesses

root@dlp:~#
mariadb -h 127.0.0.1 -u root -p -e "show variables like 'hostname';"

Enter password:
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| hostname      | 157db0791556 |
+---------------+--------------+

root@dlp:~#
mariadb -h 127.0.0.1 -u ubuntu -p -e "show databases;"

Enter password:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ubuntu_db          |
+--------------------+

root@dlp:~#
curl 127.0.0.1

Compose Test on Nginx
[3] Other basic operations of Podman Compose are follows.
# verify state of containers

root@dlp:~#
podman-compose ps

CONTAINER ID  IMAGE                             COMMAND               CREATED        STATUS        PORTS                   NAMES
157db0791556  docker.io/library/mariadb:latest  mariadbd              6 minutes ago  Up 6 minutes  0.0.0.0:3306->3306/tcp  root_db_1
e448c6fa76fd  localhost/root_web:latest         /usr/sbin/nginx -...  6 minutes ago  Up 6 minutes  0.0.0.0:80->80/tcp      root_web_1

# show logs of containers

root@dlp:~#
podman-compose logs

157db0791556 2026-05-07 00:31:46+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:12.2.2+maria~ubu2404 started.
157db0791556 2026-05-07 00:31:46+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
157db0791556 2026-05-07 00:31:46+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:12.2.2+maria~ubu2404 started.
157db0791556 2026-05-07 00:31:46+00:00 [Note] [Entrypoint]: Initializing database files
157db0791556 2026-05-07 00:31:47+00:00 [Note] [Entrypoint]: Database files initialized
157db0791556 2026-05-07 00:31:47+00:00 [Note] [Entrypoint]: Starting temporary server
157db0791556 2026-05-07 00:31:47+00:00 [Note] [Entrypoint]: Waiting for server startup
.....
.....

# run any commands inside a container
# container name is just the one set in [docker-compose.yml]

root@dlp:~#
podman-compose exec db /bin/bash

root@157db0791556:/# exit

# stop application and also shutdown all containers

root@dlp:~#
podman-compose stop

root_web_1
root_db_1

# start a service alone in application
# if set dependency, other container starts

root@dlp:~#
podman-compose up -d web

root_web_1

root@dlp:~#
podman-compose ps

CONTAINER ID  IMAGE                             COMMAND               CREATED        STATUS                     PORTS                   NAMES
157db0791556  docker.io/library/mariadb:latest  mariadbd              9 minutes ago  Exited (0) 51 seconds ago  0.0.0.0:3306->3306/tcp  root_db_1
e448c6fa76fd  localhost/root_web:latest         /usr/sbin/nginx -...  9 minutes ago  Up 24 seconds              0.0.0.0:80->80/tcp      root_web_1

# remove containers in application

root@dlp:~#
podman rm root_db_1

root_db_1
root@dlp:~#
podman rm root_web_1

root_web_1
Matched Content