0

I have 2 docker composes , one is Infrastructures and the second is Appplications.

I need a direct line from Appplications => Infrastructures , to run migrations on a Postresql container in Appplications docker ,and it (Infrastructures) must be listening before make requests from Appplications.

Infrastructures :

version: "3"

networks:
  shared_network:
    driver: bridge

services:

  # PostgreSQL
  my_postgres:
    image: postgres:latest
    environment:
      .... // ENVS
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5432"]
      interval: 30s
      timeout: 10s
      retries: 15
    networks:
      - shared_network
      
      
      ... more infrastructures

Applications :

version: "3"

networks:
  shared_network:
    driver: bridge

services:
  # Employees Service
  emps:    
    build:
      context: ./emps_service
      dockerfile: ./Dockerfile
    ports:
      - "9000:9000"
    networks:
      - shared_network
      
      
      
      
      
      ... More apps

I'm using default.yaml for Sequelize :

... more definitions 


sequelize:
  database: some_random_db
  host: my_postgres
  user: xxxx
  password: yyyy
  dialect: postgres  
  seederStorage: "sequelize"

and when I run docker-compose up , twice , first for the Infrastructures , and only once it's up another docker-compose up for the Applications , I get :

**SequelizeHostNotFoundError: getaddrinfo ENOTFOUND my_postgres**

How can we fix this ?

JAN
  • 21,236
  • 66
  • 181
  • 318
  • Is this on a different folder? if you define the network external, it has to work. – Jinna Balu Jan 04 '21 at 14:54
  • @JinnaBalu: Yes ,on different folders , each `docker-compose` with its own files on different folder – JAN Jan 04 '21 at 15:02
  • With different `docker-compose.yml` files in different directories, Compose treats these as two totally separate projects, and there are actually two different `shared_network`s, one in each project. The linked question describes how to connect them together (by declaring one of the networks as `external: true`). – David Maze Jan 04 '21 at 15:15
  • @DavidMaze: I've checked out the links you've provided even before posting my question , and still they do not work. I'll post another question with the same details so you'll be able to see for yourself. Thanks – JAN Jan 05 '21 at 07:40

0 Answers0