0

The following setup:

I have "project A" set up with docker/docker-compose, that is a website. Then i have a different bundle - lets say "project B" set up with docker/docker-compose, that is a search-backend (elastic, etc).

Both are not composed in one file, so they dont know anything about eacht other.

Both containers/networks run locally (development). How do i add a hostname to a container in project A, that could request a container in project B?

i tried the "extra_host" option of docker-compose, but i dont know where to link my extra_host.

What i need is a bridge between 2 networks.

Philipp Wrann
  • 1,751
  • 3
  • 19
  • 29
  • maybe this can help: https://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container – Stefano Mar 03 '20 at 13:18

1 Answers1

2

if you are using docker-compose, you can assign the same network for both files and then you can reference them using the service name (you also need to create the network in this case)

docker-compose 1

version: '3.7'

networks:
  my-network:
    external: true

services:
  service-nr-1:
    image: MY-DOCKER-IMAGE
    environment:
      SERVICE-A: service-nr-2
    networks:
      - my-network

docker-compose 2

version: '3.7'

networks:
  my-network:
    external: true

services:
  service-nr-2:
    image: MY-DOCKER-IMAGE
    environment:
      SERVICE-A: service-nr-1
    networks:
      - my-network
Al-waleed Shihadeh
  • 2,697
  • 2
  • 8
  • 22