Docker Community Forums

Share and learn in the Docker community.

Docker swarm load balanced ip, or cluster ip?

Hi all, I have a docker swarm setup with 1 master node and 3 worker nodes. I want to install a stack, (for example home-assistant) and scale it that it uses the 3 worker nodes to run on. How can I config it that they all use the same published ip (that I can reach from my workstations or other devices?)

You cant, but just because you use http://node1, dosnt mean that its node1’s container you’re going to hit.
Internally it will loadbalance to the right nodes.

what you want is maybe somekind of loadbalancer in front, maybe https://traefik.io/ ?

Does this means that my master node will be my front-end node? (if I install traefik on it)

It depends!
You could say that traefik should only run on the master, via a constraint
Which I would do.

I dont know your network or how technical it is but normally you would have some sort of enterprise loadbalancer in front which has some kind of failover, but its not easy to make at home since it requires in most case enterprise hardware.

Well, I have for example: master(192.168.1.20) node-1(192.168.1.21) node-2(192.168.1.22) node-3(192.168.1.23)
If the containers would all be reachable via the master ip its ok, but I don’t want to lookup where what container is running to connect to that machine then. (If I deploy a stack, sometimes it will put it on node-3 or node-1,… and if I want to connect to the ui I have to go to node-3:port)

So if I get this right, with installing traefik on my master node it can open a port for a stack that runs on my workers, and my clients just have to go to the master node on the port given by traefik?

(sorry if my questions are a bit noobish, I’m learning here)

The cool thing about traefik, is that you can deploy it in the swarm, and if you configure your homeassistant service correctly, traefik will automatically see your homeassistant and just start to loadbalance.

BUT, you should also still be able to access your homeassitant IF you type in the hostname of the master and the port you defined

1 Like

Ok, thanks! I will have a look at it, and play with it!