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

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:

  • Docker Expected Runs in Foreground but Runs in Background
  • Should I make a service for shared Docker dependencies?
  • AWT error while trying to build Jenkins Docker image based on Alpine -
  • Why is docker build taking so long to run?
  • Docker-compose container using host DNS server
  • Using docker bridge network IP to access vhost in apache container
  • 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.

  • How can I setup #Spark/#Kafka on Docker ?
  • connecting to services on docker host from docker container
  • Using X11-forwarding for Docker containers
  • Cannot finde module 'express' (node app with docker)
  • Development environment setup for Mac and CentOS using Docker
  • Docker Postgres - PDO exception get
  • 2 Solutions collect form web for “Can not connect nodes to docker swarm master (using zookeeper)”

    Can you verify that the addresses you’re advertising are actually reachable from the manager instance? i.e., does docker -H $(docker-machine ip machine-s01):2375 info return a valid result?

    (Note that this subshell won’t work inside the manager VM, just on your original client.)

    Maybe your problem is that the started Docker Machine instances are listening on :2376 with TLS, but your started Swarm containers are trying to advertise and connect to :2375 without any TLS settings specified?

    What do the docker logs for the Swarm containers say?

    It looks like you’re connecting to the “Swarm master” machine through the Docker API, not the Swarm API. Because of this, Docker will always deploy containers on the host you’re connected to, and does not take advantage of Swarm scheduling the containers on the right host.

    To connect to the Swarm API, add the --swarm option when running docker-machine env, so in your case:

    eval "$(docker-machine env --swarm machine-smaster)"
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.