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:

  • Setting Rails/Rack Environment When Using Docker Compose
  • Kubernetes node Device port (USB) maping to POD? Or Swarm service --device mapping
  • IdentityServer4: How to load Signing Credential from Cert Store when in Docker
  • Crontab doesn't have credentials
  • Bad gateway error on target website configured using the “nginx-proxy” docker container
  • how to list the nodes in docker swarm via api call?
  • 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.

  • build docker image with dockerfile by jenkins
  • Start up docker container without dockerfile
  • running solr instance inside docker
  • How to bind a port when using docker-py to create a service? [duplicate]
  • How to change dockers default network?
  • Less awkward method of using all available CPUs in Docker container:
  • 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.