C
C
chincharovpc2021-04-05 11:47:32
go
chincharovpc, 2021-04-05 11:47:32

How to connect two docker containers?

I created an authorization service and I want to connect to it through another service.
Tried to connect via addresses
auth_service:9101
auth:9101
localhost:9101

gives an error

Post \"http://auth_service:9101/api/v1/auth/sign-in\": dial tcp: lookup auth_service on 127.0.0.11:53: read udp 127.0.0.1:5989
5->127.0.0.11:53: i/o timeout


How to solve the problem?

docker-compose file of the Authorization service
version: '3.4'

services:
  app:
    image: auth
    container_name: auth
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 9101:9101
    depends_on:
      - postgresql
    volumes:
      - ./.bin/:/root/
      - ./configs/:/root/configs/
    env_file:
      - .env
    networks:
      - auth_service

networks:
  auth_service:


Broker service docker-compose file
version: '3.4'

services:
  app:
    image: brocker
    container_name: brocker
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 9100:9100
    depends_on:
      - pstgrsql
    volumes:
      - ./.bin/:/root/
      - ./configs/:/root/configs/
    env_file:
      - .env
    networks:
      - brocker_service

networks:
  brocker_service:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-04-05
@dmtrrr

They are in different networks. For simplicity, you can do one docker-compose.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question