Docker Community Forums

Share and learn in the Docker community.

internal routing in overlay networks


(Nimble12345) #1

hello,

in https://docs.docker.com/network/overlay/#bypass-the-routing-mesh-for-a-swarm-service

it’s said that routing mesh is used for when you connect to “published port”

so here is use case when ports are not published:

lets say I have 2 swarm workers (worker1 and worker2), 2 containers in each in global mode (nginx and mongos), and having overlay network in this setup

the docker-compose schematically is like this:

version: ‘3.3’

services:
mongos:
image: mongos
deploy:
mode: global

nginx:
image:nginx
deploy:
mode: global

so question is: when I do ping or any other kind of traffic from nginx on worker1 to mongos (using e.g. ping $stackname_mongos) , will the traffic be always routed to mongos on worker1 or there are some chances that it will be routed to mongos container on worker2?

if it will be somehow routed to mongos on worker2 how can I be sure the traffic be always routed to mongos on worker1?