0

I'm developing microservices based on node JS/Express with multiple containers. Different group of containers deployed with different docker compose. Eg. One docker compose contains 4 docker containers, while other docker compose contains 3 docker containers. Docker compose created automatic network for each docker compose, eg. BackendA_default and BackendB_default, thus each backend cannot talk to each other as they're on separate network. Even if I specify the network to eg. backend, it will still show BackendA_backend instead of just 'backend' network. I already tried using 'bridge' and 'host' network, it still doesn't work.

How do I make this 2 groups of docker network connect to each other ?

Reno2099
  • 33
  • 4

1 Answers1

0

Create your networks outside of docker-compose using docker network create:

docker network create my-app-network

And then use them in your compose files as an "external" network:

version: 3

services:
  database:
    image: docker.io/postgres
    network: my-app-network

networks:
  default:
    external: true
    name: my-app-network

This will allow you to attach containers from multiple compose stacks to the same network.

larsks
  • 277,717
  • 41
  • 399
  • 399