Docker Compose and multiple subnets

dockerdocker-compose

I'm struggling with Docker Compose (version 2 or 3).
I'm trying to add multiple subnets, so various services can reach each other, but get assigned IPv4 addresses from different subnets.

This is my current configuration:

networks:
  custom:
    driver: "bridge"
    ipam:
      driver: default
      config:
        - subnet: 10.10.10.0/16
          gateway: 10.10.10.1
        - subnet: 100.100.100.0/16
          gateway: 100.100.100.1

But I get the error:

Creating network "docker-setup-test_custom" with driver "bridge"
ERROR: Pool overlaps with other one on this address space

Best Answer

You can specify the network config as specified in the documentation:

https://docs.docker.com/compose/networking/#specify-custom-networks

Otherwhise I believe all containers in the same docker compose can communicate without network config.

Related Topic