Docker Community Forums

Share and learn in the Docker community.

Can not connect nodes to docker swarm master (using zookeeper)


(Casertap) #1

I am building my docker swarm cluster in a sandbox.
I have 1 zookeeper on a machine for discovery, 1 swarm master and 2
swarm nodes.
I try to connect them but when I try to run my docker run commands on
the swarm master, it does not distribute the work to the nodes.
Also when I do docker info on the swarm master I can see that the nodes are not connected.
I do not know what I am doing wrong.
Here are the step to reproduce my problem:

I have an empty pwd/data folder and a pwd/config folder with my zoo.cfg:

tickTime=2000
dataDir=/tmp/zookeeper
clientPort=2181
initLimit=5

#— CREATE ZOO —

docker-machine create --driver virtualbox zoo1
docker-machine start zoo1
eval $(docker-machine env zoo1)
docker pull jplock/zookeeper
docker run -p 2181:2181 -v pwd/conf:/opt/zookeeper/conf -v pwd/data:/tmp/zookeeper jplock/zookeeper
docker-machine ip zoo1 #############192.168.99.100

#— CREATE CLUSTER —

docker-machine create --driver virtualbox --swarm --swarm-master machine-smaster
docker-machine create --driver virtualbox --swarm machine-s01
docker-machine create --driver virtualbox --swarm machine-s02

eval "$(docker-machine env machine-smaster)"
docker run -p 2375:2375 -d -t swarm manage -H 0.0.0.0:2375 --advertise $(docker-machine ip machine-smaster):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm

sleep 10

eval "$(docker-machine env machine-s01)"
docker run -d swarm join --advertise $(docker-machine ip machine-s01):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm

eval "$(docker-machine env machine-s02)"
docker run -d swarm join --advertise $(docker-machine ip machine-s02):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm

If I run some containers:

eval "$(docker-machine env machine-smaster)"
docker run hello-world

The work is not dispatched to nodes (it is run by the master).
If I run docker info:

eval "$(docker-machine env machine-smaster)"
docker info

I do not see the swarm nodes.
I asked this question on stackoverflow ( http://stackoverflow.com/questions/36560681/can-not-connect-nodes-to-docker-swarm-master-using-zookeeper ) and someone told me to do

eval “$(docker-machine env --swarm machine-smaster)”

This give me an error:

Error checking TLS connection: Connection to Swarm cannot be checked but the certs are valid. Maybe swarm is not started
eval "$(docker-machine env machine-smaster)"
docker ps
f5bb895cdad9 swarm “/swarm manage -H 0.0” 51 seconds ago Up 48 seconds 0.0.0.0:2375->2375/tcp tiny_kowalevski

I tried to run the swarm manager using tls but it does not solve the problem

docker run -p 2375:2375 -d -t -v /var/lib/boot2docker:/certs:ro swarm manage --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server.pem --tlskey=/certs/server-key.pem -H 0.0.0.0:2375 --advertise $(docker-machine ip machine-smaster):2375 zk://192.168.99.101:2181/swarm