Docker swarm manager cannot recognize swarm nodes

I follow these steps to create a cluster of Docker clusters.

  • 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

  • create a swarm manager
    $ docker-machine create -d virtualbox node1
    $ docker run -d -p 4000: 4000 swarm manage -H: 4000 --replication - advertisement $ (ip dock machine node1): 4000 consul: // $ (ip dock machine mh-keystore): 8500

  • 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

  • login node1
    $ docker-machine ssh node1
    $ docker -H: 4000 info

But this command output

(unknown): 192.168.99.106:2375(node2 ip)
β”” ID:
β”” Status: Pending
β”” Containers: 0 β”” Reserved processors: 0/0
β”” Reserved memory: 0 B / 0 B
β”” Shortcuts:
β”” Error: Unable to connect to the Docker daemon. Is the docker daemon on this host? ...

How can i fix this? I already checked node2 and it works well.

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

[Refresh] Another approach does not 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 information is displayed by mhs-demo1 ip, but the information is still unknown.

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

TLS connection validation error: "node1" is not a master swarm. --swarm flag is for use with swarm masters. Does this cause an error? Why using the swarm control command to configure is not a swarm master?

This is so strange. How to 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 the swarm command?

I want to use the swarm command because I do not want to declare a swarm master when I create it.

+5
source share
3 answers

Why do you use a docker machine only to run node? You can use the docker machine to configure node ready to run. You can follow this guide https://docs.docker.com/engine/userguide/networking/get-started-overlay/

0
source

Try deleting this file with

 sudo rm /etc/docker/key.json 

Then restart docker with:

 sudo service docker restart 

At this point, docker will create a new key.json file and your wizard will be able to find your workers. This happens sometimes when you use the same image for all of your work nodes, but it is easy to fix.

0
source

In docker 1.12, swarm mode is available. There is no need to store the keystore for the cluster.

just do the following: https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/

0
source

All Articles