DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Keep Your Application Secrets Secret
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?
  • Docker Bake: A Modern Approach to Container Building

Trending

  • The Human Side of Logs: What Unstructured Data Is Trying to Tell You
  • Testing SingleStore's MCP Server
  • Vibe Coding With GitHub Copilot: Optimizing API Performance in Fintech Microservices
  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  1. DZone
  2. Software Design and Architecture
  3. Containers
  4. Podman Compose vs Docker Compose

Podman Compose vs Docker Compose

Take a look at Podman Compose, exploring how to use Compose files according to the Compose Spec in combination with a Podman backend.

By 
Gunter Rotsaert user avatar
Gunter Rotsaert
DZone Core CORE ·
Aug. 02, 23 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
13.3K Views

Join the DZone community and get the full member experience.

Join For Free

In this blog, you will take a look at Podman Compose. With Podman Compose, you can use compose files according to the Compose Spec in combination with a Podman backend. Enjoy!

Introduction

A good starting point and a must-read is this blog provided by RedHat. In short, Podman Compose is not directly maintained by the Podman team, and neither is Docker Compose, of course. Podman Compose has a more limited feature set than Docker Compose and in general, it is advised to use Kubernetes YAML files for this purpose. See "Podman Equivalent for Docker Compose" for how this can be used. However, the Podman team will fix issues in Podman when required for Podman Compose. It is also possible to use Docker Compose in combination with Podman, as is described in the post "Use Docker Compose with Podman to Orchestrate Containers on Fedora Linux."

In this post, you will use Podman Compose to run some basic containers. Sources used in this blog are available at GitHub and the container image is available at DockerHub. The container image is built in a previous blog post "Is Podman a Drop-in Replacement for Docker?". You might want to check it out when you want to know more about Podman compared to Docker. The image contains a basic Spring Boot application with one REST endpoint which returns a hello message.

Prerequisites

The prerequisites needed for this blog are:

  • Basic Linux knowledge
  • Basic container knowledge
  • Basic Podman knowledge
  • Basic Docker Compose knowledge

Podman Compose With One Container

Let’s start with a basic single container defined in compose file docker-compose/1-docker-compose-one-service.yaml. One service is defined as exposing port 8080 in order to be able to access the endpoint.

YAML
 
services:
  helloservice-1:
    image: docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
    ports:
    - 8080:8080


It is assumed that you have Podman installed already. Execute the following command from the root of the repository.

Shell
 
$ podman-compose -f docker-compose/1-docker-compose-one-service.yaml up -d
Error: unknown shorthand flag: 'f' in -f


As expected, this does not work. Podman Compose is not included or available when you have installed Podman. Docker Compose does not require an additional installation. Podman Compose is a community project not maintained by the Podman team and that is why it is not part of the Podman installation.

Installation instructions for Podman Compose can be found on the Podman Compose GitHub pages. The easiest way is to use pip, the Python package installer. This requires an installed Python version and pip.

Shell
 
$ pip3 install podman-compose


Run the Podman Compose command again.

Shell
 
$ podman-compose -f docker-compose/1-docker-compose-one-service.yaml up -d
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 3.4.4
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=docker-compose', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'docker-compose_default']
podman run --name=docker-compose_helloservice-1_1 -d --label io.podman.compose.config-hash=b2928552303ab947ea3497ef5e1eff327c1c9672a8454f18f9dbee4578061370 --label io.podman.compose.project=docker-compose --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@docker-compose.service --label com.docker.compose.project=docker-compose --label com.docker.compose.project.working_dir=/home/.../mypodmanplanet/docker-compose --label com.docker.compose.project.config_files=docker-compose/1-docker-compose-one-service.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=helloservice-1 --net docker-compose_default --network-alias helloservice-1 -p 8080:8080 docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
302dcf140babae07c416e8556e11fc13918bd1fe3c52b737f4ab091f3599291e
exit code: 0


Verify whether the container has started successfully.

Shell
 
$ podman ps
CONTAINER ID  IMAGE                                                      COMMAND     CREATED             STATUS                 PORTS                   NAMES
3104b5a4c418  docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT              About a minute ago  Up About a minute ago  0.0.0.0:8080->8080/tcp  docker-compose_helloservice-1_1


Verify whether the endpoint can be reached.

Shell
 
$ curl http://localhost:8080/hello
Hello Podman!


Shut down the container.

Shell
 
$ podman-compose -f docker-compose/1-docker-compose-one-service.yaml down
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 3.4.4
** excluding:  set()
podman stop -t 10 docker-compose_helloservice-1_1
docker-compose_helloservice-1_1
exit code: 0
podman rm docker-compose_helloservice-1_1
3104b5a4c4189777b21c2658a3d3c4df91b3f804d5c9bced63532f0318e9e9df
exit code: 0


Running a basic service just worked.

Podman Compose With Two Containers

Let’s run two containers defined in compose file docker-compose/2-docker-compose-two-services.yaml. One service is available at port 8080 and the other one at port 8081.

Shell
 
services:
  helloservice-1:
    image: docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
    ports:
    - 8080:8080
 
  helloservice-2:
    image: docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
    ports:
      - 8081:8080


Run the Compose file from the root of the repository.

Shell
 
$ podman-compose -f docker-compose/2-docker-compose-two-services.yaml up -d
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 3.4.4
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=docker-compose', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'docker-compose_default']
podman run --name=docker-compose_helloservice-1_1 -d --label io.podman.compose.config-hash=d73c6cebbe901d7e4f27699b4308a39acaa4c3517293680c24ea1dce255177cf --label io.podman.compose.project=docker-compose --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@docker-compose.service --label com.docker.compose.project=docker-compose --label com.docker.compose.project.working_dir=/home/.../mypodmanplanet/docker-compose --label com.docker.compose.project.config_files=docker-compose/2-docker-compose-two-services.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=helloservice-1 --net docker-compose_default --network-alias helloservice-1 -p 8080:8080 docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
ff344fb5e22800c2c7454d66572bbcad22a47536d0dc930960ea06844b7838f3
exit code: 0
['podman', 'network', 'exists', 'docker-compose_default']
podman run --name=docker-compose_helloservice-2_1 -d --label io.podman.compose.config-hash=d73c6cebbe901d7e4f27699b4308a39acaa4c3517293680c24ea1dce255177cf --label io.podman.compose.project=docker-compose --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@docker-compose.service --label com.docker.compose.project=docker-compose --label com.docker.compose.project.working_dir=/home/.../mypodmanplanet/docker-compose --label com.docker.compose.project.config_files=docker-compose/2-docker-compose-two-services.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=helloservice-2 --net docker-compose_default --network-alias helloservice-2 -p 8081:8080 docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT
e88b6d4eb33b8869b2fa7c964cd153a2920558a27b7bc8cf0d2b9f4d881a89ee
exit code: 0


Verify whether both containers are running.

Shell
 
$ podman ps
CONTAINER ID  IMAGE                                                      COMMAND     CREATED         STATUS             PORTS                   NAMES
ff344fb5e228  docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT              35 seconds ago  Up 35 seconds ago  0.0.0.0:8080->8080/tcp  docker-compose_helloservice-1_1
e88b6d4eb33b  docker.io/mydeveloperplanet/mypodmanplanet:0.0.1-SNAPSHOT              33 seconds ago  Up 33 seconds ago  0.0.0.0:8081->8080/tcp  docker-compose_helloservice-2_1


Verify whether both endpoints are accessible.

Shell
 
$ curl http://localhost:8080/hello
Hello Podman!
$ curl http://localhost:8081/hello
Hello Podman!


In the output after executing the podman-compose command, you can see that a default network docker-compose_default is created. A network alias helloservice-1 is created for container 1 and a network alias helloservice-2 is created for container 2.

Enter container 1 and try to access the endpoint of container 2 using the network alias. Beware to use the internal port 8080 instead of the external port mapping to port 8081!

Shell
 
$ podman exec -it docker-compose_helloservice-1_1 sh
/opt/app $ wget http://helloservice-2:8080/hello
Connecting to helloservice-2:8080 (10.89.1.3:8080)
saving to 'hello'
hello                100% |*********************************************************************************************************************|    13  0:00:00 ETA
'hello' saved


As you can see, the services can access each other using the network alias.

Finally, stop the containers.

Shell
 
$ podman-compose -f docker-compose/2-docker-compose-two-services.yaml down
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 3.4.4
** excluding:  set()
podman stop -t 10 docker-compose_helloservice-2_1
docker-compose_helloservice-2_1
exit code: 0
podman stop -t 10 docker-compose_helloservice-1_1
docker-compose_helloservice-1_1
exit code: 0
podman rm docker-compose_helloservice-2_1
e88b6d4eb33b8869b2fa7c964cd153a2920558a27b7bc8cf0d2b9f4d881a89ee
exit code: 0
podman rm docker-compose_helloservice-1_1
ff344fb5e22800c2c7454d66572bbcad22a47536d0dc930960ea06844b7838f3
exit code: 0


Conclusion

Podman Compose works with some basic Compose files. However, Podman Compose lacks features compared to Docker Compose. This list cannot be easily found (at least, I could not find it). This means that it is a risk of using Podman Compose instead of Docker Compose. Besides that, RedHat itself recommends using Kubernetes YAML files instead of Compose files. If you are using Podman, it is better to use the Kubernetes YAML files for container orchestration.

YAML Docker (software) shell Container

Published at DZone with permission of Gunter Rotsaert, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Keep Your Application Secrets Secret
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?
  • Docker Bake: A Modern Approach to Container Building

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!