Search code examples
docker-composepodman

How to enable inter container communication using podman-compose


we basically have a docker-compose.yml file looking like this:

services:
  db:
    image: db
    container_name: db
    ports:
      - 7474:7474
      - 7687:7687
    networks:
      - com
  backend:
    image: backend
    container_name: backend
    ports:
      - 8080:8080
    environment:
      # Lookup host of db on docker-compose network
      - DB_HOST=db:7687
    depends_on:
      - db
    networks:
      - com
networks:
  com: {}

When I am starting my containers using docker-compose up on my local machine where I use docker as a backend I can see that the backend can actually lookup the address of my db container.

When I am using podman-compose up or docker-compose up in combination with the podman backend to do the same, the host cannot be resolved. I thought that podman would handle inter container communication by creating a network for the containers like docker-compose does. Am I doing something wrong?

I just checked and podman did not create a pod for the containers to run in. I assumed that it would create one pod to run all containers in by default. That way the containers should at least be able to reach each other via localhost. But as there is no pod, localhost isn't working, too. Does somebody know what the problem is?


Solution

  • Upgrading to a newer Podman version did fix the problem. For more details take a look at this Github issue: https://github.com/containers/podman/issues/11457#issuecomment-916260531