I’m working to build a Swarm cluster; but there’s one question on launching docker: can docker use zookeeper/etcd to discover Swarm’s host?
Hi,
Yes, Swarm can use Zookeeper and Etcd as discovery backends. You can find the documentations here. https://docs.docker.com/swarm/discovery/
Regards
But how about docker client to connect to Swarm? For example, when I run “docker -H 0.0.0.0:2375 run hello-world” to launch image by Swarm, can I replace 0.0.0.0:2375 by “zk://x.x.x.x:2181”? Or, is there any solution to achieve the this target when Swarm failover to other host?
Hi,
This documentation has more details for you. https://docs.docker.com/swarm/multi-manager-setup/
Swarm multi-manager setup uses the discovery service to discover swarm masters and to choose leader from the existing masters.
When launching containers using docker client you will have to point to the right swarm master. As of now we cannot point to zk or etcd to fetch the active swarm master and submit the docker run.
To automate this what you can do is read from zookeeper the active master and export the DOCKER_HOST variable, so that docker client can read the variable and connect to the right swarm master.
Regards
Ranjan
Thanks for your reply, that’s helpful.
Just one more question, is there any plan to do so? For example, export DOCKER_HOST to zookeeper, so docker can connect to current Swarm’s leader.
I am not sure about that, It would be great if you can raise a feature request for the same.
Regards
OK, thanks :), let me raise this requirement.