Docker Community Forums

Share and learn in the Docker community.

internal routing in overlay networks docker swarm


(Tetlika) #1

hey, question about routing in swarm overlay network

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?

many thanks