Docker Community Forums

Share and learn in the Docker community.

Addressing multiple non docker-swarm services on LAN from within swarm

We have a scenario where we need to contact multiple micro-services outside swarm from services inside swarm. Before moving to swarm, we used --net=host to make the host machines’ hosts file to be available for containers but now we are struggling to achieve the same.

We tried mounting host machine’s /etc/hosts to container’s /etc/hosts and could achieve what was needed but the problem is when we update the host machine’s hosts file the change is not reflected inside the container.
i used --mount type=bind,source=/etc/hosts,target=/etc/hosts in docker service create command.

What are the options to connect to non docker-swarm services on LAN from within swarm?