Can I use host network for docker stack deployment in a Docker Swarm cluster. Basically I want to assign host IP address to all the containers in Docker Swarm.
1 Answers
Even though you can create a Swarm-aware macvlan (see: collabnix blog post) in an ip-range within your subnet, which will allow services to get ips from this range, Swarm does not support to set fixed ip's for swarm services or it's tasks (=containers).
Either you run Swarm with macvlan and live with random ip's in the declared ip-range, or you live without Swarm and use plain containers with macvlan, which allow fixed ip's in the declared ip-range.
I am working in containerized environments since roughly 6 years now and neither macvlan, nor fixed container ip's where ever necessary.
... usualy people trying to enforce old patterns from the vm world to the container world end up thinking they need this as a solution, though high likely there is a better and more docker-like solution for the problem domain.

- 661
- 3
- 15
-
Thanks @Metin. I have a Docker Swarm cluster hosted on AWS and I am trying to set up a druid cluster in docker swarm. I am running a service with 3 replicas within the Swarm. This service runs in Master slave mode. So whenever I submit a request to this service via a browser or python client, it reroutes the requests to other nodes. So,my client tries to connect to the container ip within the swarm but can never connect to this service. Whenever I scale down this service to only 1 replica, everything works fine.Trying to figure out how to connect to this service with multiple replicas. – Swapnil Dec 20 '20 at 23:18
-
I have no idea how the bits and pieces of druid work. Though, from a brief look at the architecture diagram I would recommend to check weather all replicas of the broker component share their state, and weather a public uri/hostname can be configured for them. – Metin Dec 21 '20 at 16:21
-
Yeah I get it. My questions is more around how to handle scenarios in a docker swarm where internal re routing happens and how an external client connects to such services. – Swapnil Dec 21 '20 at 17:49