Can I use host network for docker stack deployment in a Docker Swarm cluster

503 Views Asked by At

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

There are 1 best solutions below

3
On

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.