Docker swarm manager cannot recognize swarm nodes

I follow these steps to create Docker swarm cluster.

  1. create Cunsol
    $ docker-machine create -d virtualbox mh-keystore
    $ eval “$(docker-machine env mh-keystore)”
    $ docker run -d \
    -p “8500:8500” \
    -h “consul” \
    progrium/consul -server -bootstrap

  2. Assign public IP to docker
  3. Can't start docker-compose with systemd: “aufs au_opts_verify: dirperm1 breaks the protection by the permission bits on the lower branch” error
  4. Use host networking and additional networks in docker compose
  5. Silently Installing pecl modules (e.g. pecl_http) Inside a Docker Container?
  6. Expose mongo port in other container
  7. Installing pure-ftpd in docker (Debian wheezy), error 421
  8. create swarm manager
    $ docker-machine create -d virtualbox node1
    $ docker run -d -p 4000:4000 swarm manage -H :4000 –replication — advertise $(docker-machine ip node1):4000 consul://$(docker-machine ip mh-keystore):8500

  9. create swarm node
    $ docker-machine create -d virtualbox node2
    $ docker run -d swarm join –advertise=$(docker-machine ip node2):2375 consul://$(docker-machine ip mh-keystore):8500

  10. login node1
    $ docker-machine ssh node1
    $ docker -H :4000 info

But this instruction output

(unknown): 192.168.99.106:2375(node2 ip)
└ ID:
└ Status: Pending
└ Containers: 0
└ Reserved CPUs: 0 / 0
└ Reserved Memory: 0 B / 0 B
└ Labels:
└ Error: Cannot connect to the Docker daemon. Is the docker daemon running on this host?….

How can I fix this ?
I have already check node2 and it run well.

[Update] I follow this page and it works well. But I still wan’t to know how set up swarm cluster without docker-machine.

[Update] Another approach doen’t work either.

docker-machine create -d virtualbox \
    --swarm \
    --swarm-discovery="consul://$(docker-machine ip mh-keystore):8500" \
    --engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500" \
    --engine-opt="cluster-advertise=eth1:2376" \
  mhs-demo1

Node1 docker info appear mhs-demo1 ip but info still unknown..

[Update]
when I type eval $(docker-machine env –swarm node1)
It show

Error checking TLS connection: “node1” is not a swarm master. The
–swarm flag is intended for use with swarm masters Does this cause error ? Why using swarm manager instruction to set up is not swarm
master?

It’s so strange. How can I get the same result as

docker-machine create \ -d virtualbox \ --swarm --swarm-master \ --swarm-discovery="consul://$(docker-machine ip mh-keystore):8500" \ --engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500" \ --engine-opt="cluster-advertise=eth1:2376" \ mhs-demo0

using swarm instruction?

I want to use swarm instruction because I don’t want to declare swarm master when I create it.

  • Docker container does not give me a shell
  • Migrating existing Docker containers to Docker Compose
  • clone docker images from local server?
  • install mysql in docker and expose mysql service to outside
  • Unable to do port forwarding: socat not found. Kubernetes on Docker
  • DockerFile / Switch from ubuntu:latest to alpine:3.3
  • 3 Solutions collect form web for “Docker swarm manager cannot recognize swarm nodes”

    Why are you using docker-machine just to start a node? You can use docker machine to setup your node with swarm ready to go..
    You can follow this tutorial
    https://docs.docker.com/engine/userguide/networking/get-started-overlay/

    Try deleting this file with:

    sudo rm /etc/docker/key.json
    

    Then restart docker with:

    sudo service docker restart
    

    At this point docker will make a new key.json file and your master should be able to find your workers. This happens sometimes when you use the same image for all your worker nodes, but its an easy fix.

    In docker 1.12 swarm mode is directly available. There is no need for a key value store for the cluster.

    just follow the this : https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.