Docker Community Forums

Share and learn in the Docker community.

Docker Engine Swarm mode and hostnames

docker

(Richardatwork) #1

I suspect this is similar to this post, but rather than clog that thread up, I thought I’d start a new one.

We have an application that is made up of a number of services which is working well with just docker engine (via docker-compose). Some of the services store state (on a queue, or in a database) and for these services we need to cluster/replicate them. We’ve constructed the images so that they can be started in the same way with exactly the same configuration, as this seemed the most sensible when swarming them.

Using the host name template of {{.Service.Name}}-{{.Task.Slot}}, each of the replicated services have a unique and obvious hostname. The trouble is that the other containers can not access them via this hostname (ping: unknown host), so generally the clustering can’t work. Although our ESB can access them via the service name, which is great, the individual containers that make up the cluster need access to the individual containers, rather than through the service name, and hence the load-balancer.

Is this something that should work?

Thanks

Richard.


(Lachele) #2

Best my team can tell, the hostname isn’t used by services the way it is by containers in the non-swarm mode, and we’re having other troubles because of it. I also wonder if that’s on purpose. Here’s my post about it: Name vs hostname in swarm mode