Hello,
I have a configuration where four containers are started on a docker host.
These four containers communicate with each other using their container names.
In the compose file below, the container names are svc1,svc2,svc3,svc4
This all works fine on a single host but it has issues when i run this configuration in a swarm.
The problem is, because docker swarm uses an overlay network, if i have this configuration running on more than one docker host in a swarm, I will have multiple services called svc1,svc2,svc3 and svc4 on the one network.
So, when a service does a dns lookup for another services e.g. svc1 looks for svc2, I have no gaurentee that svc1 will find the svc2 that is running on the same docker host. Svc1 may find a svc2 that is running on a different host.
I would like to make it so that all four services on one host can only talk to themselves and have no visibility of the services running on any other host in the swarm.
Is there any way to do this?
Thanks
Regards
Stuart
version: “3.6”
services:
svc1:
image: privaterepo:5000/svc1_debian:0.5.0
networks:
- dl
deploy:
mode: global
hostname: svc1
stdin_open: true
tty: true
svc2:
image: privaterepo:5000/svc2_debian:0.5.0
networks:
- dl
deploy:
mode: global
hostname: svc2
stdin_open: true
tty: true
svc3:
image: privaterepo:5000/svc3_debian:0.5.0
networks:
- dl
deploy:
mode: global
hostname: svc3
stdin_open: true
tty: true
svc4:
image: privaterepo:5000/svc4_debian:0.5.0
networks:
- dl
deploy:
mode: global
hostname: svc4
stdin_open: true
tty: true
networks:
dl: