How to Use Docker Compose with Podman

Estimated reading time: 7 minutes

Last updated on November 8th, 2024 at 05:52 pm

Podman provides the same API and CLI commands as Docker but, Does it support Docker Compose with Podman?

The answer is Yes. After the Podman 3.0 release, you can run the Docker Compose with the Podman.

Introduction

Podman is an open-source and daemonless engine for managing and running containers using the Open Container Initiative ( OCI )

Docker provides a mature ecosystem and industry-wide adoption, while Podman focuses more on security and lightweight operations.

Podman gained much popularity from the container community, but  Podman vs Docker: choosing the right one became a common debate topic for developers.

Podman is missing the one key feature that makes it a “deal-breaker” for the container community – “Docker Compose”

Let’s explore how to use the Docker Compose with the Podman with practical examples.

What is Docker Compose?

Docker Compose is the command-line utility that orchestrates running multiple Docker containers for local development. 

Docker Compose uses YAML syntax to write your containers, volumes, and networks and then deploy the complete application stack in a single command.

what is docker compose

You can find more about what goes into YAML configuration in compose-specification documentation.

Docker Compose is a powerful tool to track your application configuration in one YAML file over running the `docker run` or `podman run` commands.

What is Podman? 

Podman, much like Docker, functions as a container management tool. While both share a common purpose, their differences lie in the underlying mechanisms, operational approaches, and containerization strategies.

what is podman?
  • Podman is Daemomless – no background service like `dockerd`
  • Rootless Containers – prioritizes security through rootless containers, and ensures safety as operations run under a user, rather than root.
  • Podman and Docker have an almost identical command-line interface (CLI) and commands.
  • Podman now supports the Docker Compose with Podman 
Podman Cheat Sheet

FREE Podman Cheat Sheet (Everything You Need, In One Place)

This is the last Podman Cheat Sheet you’ll ever need. Why?
Because it’s not just a list of commands—it’s a shortcut to make your work easier, faster, and more effective.

Stop wasting time digging through documentation. With this cheat sheet, you’ll get exactly what you need, right when you need it.

Podman Compose Example:

#1. Install the Podman packages

I’m currently on Fedora 39 fresh install. Before we start we need to install the required packages.

Bash
dnf install podman-docker podman-compose

You might wonder why podman-docker and not podman. The podman-docker package is an alias of the docker command that runs podman the docker-compatible API via a socket.

If your system has already installed Docker, You will face a conflict that needs to be solved by removing the docker-ce docker-cli package.

Bash
dnf remove docker-ce docker-ce-cli

If you want to run the Docker Compose with Podman side by side you need to modify the command slightly.

Bash
sudo dnf install podman podman-compose

#2. Start the Podman Socket

After installation, we must create the docker socket miming the docker-compose API.

Bash
systemctl --user enable --now podman.socket

Created symlink /home/devops/.config/systemd/user/sockets.target.wants/podman.socket  /usr/lib/systemd/user/podman.socket.
Bash
sudo systemctl enable --now podman.socket

Created symlink /etc/systemd/system/sockets.target.wants/podman.socket  /usr/lib/systemd/system/podman.socket.

Let’s verify the symlink for the socket.

Bash
ls -al $XDG_RUNTIME_DIR/podman/podman.sock

srw-rw----. 1 devops devops 0 Feb 9 11:22 /run/user/1000/podman/podman.sock

#3. Verify the API

Once we have the required packages installed and a symlink is created, we can verify that the API is running with the newly created socket.

Bash
curl -H "Content-Type: application/json" --unix-socket /var/run/user/$UID/podman/podman.sock http://localhost/_ping

OK

If you see the response as OK that means everything is good. Let’s move to the running Docker Compose with Podman Part.

#4. Running Docker Compose With Podman

Given docker-compose file is a sample application that runs the MYSQL database and WordPress site. You can use the same docker-compose, and copy and paste it in your project dir.

YAML
version: "3.0"
services:
  database:
    image: docker.io/library/mariadb:latest
    environment:
      - MYSQL_DATABASE=devtodevops
      - MYSQL_USER=dev
      - MYSQL_PASSWORD=super_secret
      - MYSQL_ROOT_PASSWORD=super_secret
    volumes:
      - wpdb_vol:/var/lib/mysql
  wordpress:
    image: docker.io/library/wordpress:latest
    volumes:
      - wpsite_vol:/var/www
    depends_on:
      - database
    ports:
      - 8080:80
volumes:
  wpsite_vol: {}
  wpdb_vol: {}

Let’s run the example, here you can run either docker compose up or podman compose up as both will work the same way.

podman-docker make an alias for the docker commands, even though you run docker ps or any related docker command, behind the scene, podman is working.

Bash
docker compose up -d

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
>>>> Executing external compose provider "/usr/bin/podman-compose". Please refer to the documentation for details. <<<<

podman-compose version: 1.0.6

Trying to pull docker.io/library/mariadb:latest...
Getting image source signatures
Copying blob 2c8161bee37b done   | 
Copying blob 57c139bbda7e done   | 
Writing manifest to image destination
d2df287a7ea8114207284538dc17ffb42199ab98c893a13b41ef77ab8acb9640

Trying to pull docker.io/library/wordpress:latest...
Getting image source signatures
Copying blob e1caac4eb9d2 done   | 
Copying blob e055748d0b38 done   | 
Writing manifest to image destination
d2df287a7ea8114207284538dc17ffb42199ab98c893a13b41ef77ab8acb9640

If you’ve set everything perfectly you will see the message:

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg

As mentioned running docker command is just emulating Docker CLI but running as podman.

#5. Time for Running App

First, let’s check the running docker containers:

Bash
docker ps --format "table {{.Image}}\t{{.Ports}}\t{{.Names}}"

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.

IMAGE                               PORTS                 NAMES
docker.io/library/mariadb:latest                          project_db_1
docker.io/library/wordpress:latest  0.0.0.0:8080->80/tcp  project_wp_1

We can see our application is running with mariadb wordpress containers.

Let’s open the application by going to http://localhost:8080

docker compose with podman app
Docker Compose with Podman WordPress App

Nice! Everything is working as expected!

FAQs

Can Docker compose be used with Podman?

Yes, after the Podman 3.0 release, it is possible to use Docker Compose with Podman. Podman now supports Docker Compose functionality, allowing users to manage and run containers using Docker Compose files.

Can you have Docker and Podman together?

Yes, Docker and Podman can work on the same system. However, it’s important to manage potential conflicts, especially when using both tools simultaneously. You may need to handle package installations and configurations. Instead of using podman-docker uses the podman standalone package.

Is Docker Compose still relevant?

Yes, Docker Compose remains relevant, especially for local development and running multiple Docker containers. It simplifies the deployment of complex applications by using a YAML file. While other tools like Podman Compose have gained popularity, Docker Compose continues to be widely used and supported.

Podman Cheat Sheet

FREE Podman Cheat Sheet (Everything You Need, In One Place)

This is the last Podman Cheat Sheet you’ll ever need. Why?
Because it’s not just a list of commands—it’s a shortcut to make your work easier, faster, and more effective.

Stop wasting time digging through documentation. With this cheat sheet, you’ll get exactly what you need, right when you need it.

Kashyap Merai

Kashyap Merai

Kashyap Merai, a Certified Solution Architect and Public Cloud Specialist with over 7 years in IT. He helped startups in Real Estate, Media Streaming, and On-Demand industries launch successful public cloud projects.

Passionate about Space, Science, and Computers, He also mentors aspiring cloud engineers, shaping the industry's future.

Connect with him on LinkedIn to stay updated on cloud innovations.