0

I have 2 nodes, each running a different service via a docker-compose file. Node 1 runs a service called 'rabbitmq'. Node 2 has my app which 'depends on' rabbitmq. I am using a swarm/overlay network which seems to work for other things. I cannot seem to use the 'depends_on' on node 2 for rabbitmq (or I am using it wrong...which is highly likely). I get an error that rabbitmq is not found. E.g.

NODE 1 docker-compose file:

version: '3.4'
services:
   rabbitmq:
      image: someimage/rabbitmq
      container_name: rabbitmq
      ports:
         - 15672:15672
      hostname: rabbitmq
      healthcheck:
         test: ["CMD", "curl" "-f", "http://localhost:15672"]
         interval: 10s
         timeout: 5s
         retries: 5
      networks:
         - my-net
networks:
   my-net:
      driver: overlay
      attachable: true

NODE2 docker-compose file:

version: '3.4'
services:
   myapp:
      image: myapp
      container_name: myapp
      hostname: myapp
      depends_on: 
         rabbitmq:
           condition: healthy
      networks: 
         - my-net
      

networks:
   my-net:
      driver: overlay
      external: true

When I run docker-compose "up" on node2's docker-compose file I get an error that service rabbitmq is undefined.

I have more services running in both nodes, so this is just an example. I am sure the overlay network is ok based on other services that I have that need that network up.

It has to be something simple that I am missing. At least I hope so. But my google searches didnt help.

thanks Bill

BillN
  • 31
  • 2
  • The answers to [Docker Compose wait for container X before starting Y](https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y) that do not depend on health checks (either via a `wait-for-it` script, by attempting connections to the service in a loop, or just crashing and restarting) aren't actually Docker-specific and will work for this setup too. – David Maze Nov 11 '21 at 02:31

0 Answers0