Docker Community Forums

Share and learn in the Docker community.

Can docker connect zookeeper/etcd to discover target docker server?


(Klaus1982) #1

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?

(Ranjandas) #2


Yes, Swarm can use Zookeeper and Etcd as discovery backends. You can find the documentations here.


(Klaus1982) #3

But how about docker client to connect to Swarm? For example, when I run “docker -H run hello-world” to launch image by Swarm, can I replace by “zk://x.x.x.x:2181”? Or, is there any solution to achieve the this target when Swarm failover to other host?

(Ranjandas) #4


This documentation has more details for you.

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.


(Klaus1982) #5

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.

(Ranjandas) #6

I am not sure about that, It would be great if you can raise a feature request for the same.


(Klaus1982) #7

OK, thanks :), let me raise this requirement.