-1

In a simplified example, I have 3 Docker containers located on 2 Docker networks:

Container_A : Connected to Network_1 and Network_2
Container_B : Connected to Network_1
Container_C : Connected to Network_2

When running ping Container_B from inside Container_A, the Docker network layer resolves the IP adress of Container_C instead of Contaier_B.

If I kill Container_C the name resolving will go back to the expected behaviour, but as soon as Container_C comes back online, the network layer starts resolving the wrong IP adresses again.

This has caused me a great headache and I have no idea how to fix this. Thanks for any advice.

1 Answers1

0

You should provide your config. I have written a quick docker-compose file and docker is resolving everything properly:

version: '3.7'
services:
  nginx1:
    image: nginx:alpine
    networks:
      - network1
      - network2
  nginx2:
    image: nginx:alpine
    networks:
      - network1
  nginx3:
    image: nginx:alpine
    networks:
      - network2
networks:
  network1:
    external: true
  network2:
    external: true

Obviously, before running the docker-compose, you need to run:

docker network create network1 && docker network create network2

dywan666
  • 150
  • 4
  • I am unable to create a minimal docker-compose that reproduces the same problem. This behaviour only occurrs with these specific containers. – Hannes Knutsson Apr 27 '21 at 16:11