简体   繁体   中英

Docker swarm manager cannot recognize swarm nodes

I follow these steps to create Docker swarm cluster.

First: 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

Second: 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

Third: 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  

Fourth: Login to 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 checked node2 and it runs 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 shows

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM