Multi container deployment

Hello,

I am trying to run multiple containers on a RPI4 and I am using docker-compose file for the definition of the services. Each service seems to be starting ok but seems to be failing when they try to talk to each other. Following is a sample of the definition of a couple of services, and I use the service hostname to refer to the services. Is that supported? I am also seeing errors like the following when trying to access the services:

msg="Error getting ping: Get http://edgex-core-metadata:48081/api/v1/ping: dial tcp: lookup edgex-core-metadata on 127.0.0.11:53: no such host "

Is anything missing in my docker-compose in order to allow the containers in the same network to communicate?

metadata:
    image: edgexfoundry/docker-core-metadata-go-arm64:1.2.0
    ports:
      - "127.0.0.1:48081:48081"
    container_name: edgex-core-metadata
    hostname: edgex-core-metadata
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-core-metadata
      Notifications_Sender: edgex-core-metadata
      SecretStore_TokenFile: /tmp/edgex/secrets/edgex-core-metadata/secrets-token.json
    volumes:
      - tmp-secrets:/tmp/edgex/secrets
    depends_on:
      - consul
      - mongo
      - notifications
      - vault-worker

data:
    image: edgexfoundry/docker-core-data-go-arm64:1.2.0
    ports:
      - "127.0.0.1:48080:48080"
      - "127.0.0.1:5563:5563"
    container_name: edgex-core-data
    hostname: edgex-core-data
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-core-data
      SecretStore_TokenFile: /tmp/edgex/secrets/edgex-core-data/secrets-token.json
    volumes:
      - tmp-secrets:/tmp/edgex/secrets
    depends_on:
      - consul
      - mongo
      - metadata
      - vault-worker

networks:
  edgex-network:
    driver: "bridge"

Thanks,
Marcelo

Hey Marcelo,

balenaOS had a bug where the hostname keyword wouldn’t function as expected, but it should have been fixed. For an immediate resolution, you could change the name of the services to the name of each hostname, as docker by default uses the service-name for name resolution. So, if you change the service-name ‘data’ to ‘edgex-core-data’, then the other services will be over to use edgex-core-datato connect to that container/service.

But, since we want to dig deeper into this issue. Can you please share the balenaOS and supervisor version (you can find them in the Dashboard) so we can investigate further.

Thanks!

Thanks for the explanation and I will try that.

The information you requested:

Device: RPI4
SUPERVISOR VERSION: 11.4.10
HOST OS VERSION: balenaOS 2.51.1+rev1

Thanks,
Marcelo

@odyslam Thanks for your suggestion and that fixed my issue and now all containers are up and running.

I have one more question. I need to be able to call some of the http endpoints provided by the services by external clients. What is required in order to access those endpoints?

Thanks again,
Marcelo

Hi, you can find here documentation on container networking https://www.balena.io/docs/learn/develop/runtime/#multicontainer-applications

Hello Marcelo, we opened an issue on Github from the problem you reported. Follow it here https://github.com/balena-io/balena-supervisor/issues/1379
We will keep you updated on this and if you have any further question let us know.