Search code examples
docker-machinedocker-swarm

Error response from daemon: rpc error: code = 2 desc = The swarm does not have a leader


I have created 3 nodes swarm cluster by Virtualbox using docker-machine. The three are all running and i'm able to use 'docker-machine ssh' to connect every one.There is a problem that I restart the physical machine and the cluster seems to not work,why? The follow is the details.Thanks for your guide and advice.

san@san-System-Product-Name:~$ docker-machine ls

NAME     ACTIVE   DRIVER       STATE     URL                         
SWARM   DOCKER        ERRORS
first    -        virtualbox   Running   tcp://192.168.99.100:2376           
v17.06.0-ce   
second   -        virtualbox   Running   tcp://192.168.99.101:2376           
v17.06.0-ce   
third    -        virtualbox   Running   tcp://192.168.99.102:2376           
v17.06.0-ce

The first is a leader and the second is a manager while the third is a worker.I tried to use 'docker-machine ssh first docker node ls'.

Error response from daemon:

`rpc error: code = 2 desc = The swarm does not have a leader`.

It's possible that too few managers are online. Make sure more than 
half of the managers are online.
exit status 1

san@san-System-Product-Name:~$ docker-machine ssh first docker info

Containers: 2 
Running: 0  Paused: 0  Stopped: 2 
Images: 3 
Server Version: 17.06.0-ce 
Storage  Driver: aufs
  Root Dir: /mnt/sda1/var/lib/docker/aufs  
  Backing Filesystem: extfs
  Dirs: 17
  Dirperm1 Supported: true
Logging Driver: json-file 
Cgroup Driver: cgroupfs 
Plugins:  
  Volume: local  
  Network: bridge host macvlan null overlay 
  Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog 
Swarm: pending 
  NodeID: dowdk4pzfzm85zijbo23e6xs3 
  Error: rpc error: code = 2 desc = The swarm does not have a leader. It's possible that too few managers are online. Make sure more than half of the managers are online. 
  Is Manager: true  Node Address: 192.168.99.100 
  Manager Addresses:
  192.168.99.100:2375
  192.168.99.102:2377 
Runtimes: runc 
Default Runtime: runc 
Init Binary: docker-init 
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a 
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4 
init version: 949e6fa 
Security Options: 
   seccomp   
     Profile: default
Kernel Version:
   4.4.74-boot2docker
Operating System: Boot2Docker 17.06.0-ce (TCL 7.2); HEAD : 0672754 - Thu Jun 29 00:06:31 UTC 2017 
OSType: linux 
Architecture: x86_64
CPUs: 1
Total Memory: 995.8MiB 
Name: first
ID: ACGX:Z6QQ:5KOX:7W2O:OMMM:43PB:4QES:KKGJ:IXUC:J2SW:F4SJ:QMQ4 
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false 
Debug Mode (server): true  
 File Descriptors: 24 
 Goroutines: 76 
 System Time: 2017-07-28T01:57:37.410536525Z 
 EventsListeners: 0 
Registry: https://index.docker.io/v1/
Labels:  provider=virtualbox
Experimental: false 
Insecure Registries:
  127.0.0.0/8 
Live Restore Enabled: false

san@san-System-Product-Name:~$ docker-machine ssh first docker network ls

  NETWORK ID          NAME                DRIVER              SCOPE
    22e85840407d        bridge              bridge              local
    fc3c6786739c        docker_gwbridge     bridge              local
    e294dde63753        host                host                local
    55f8e340b794        none                null                local

how could i fix this problem and use

docker node ls

on manage node?very thanks for your advice.


Solution

  • I had the same problem but I'm not sure what caused it. I was able to fix it by entering:

    docker swarm init --force-new-cluster
    

    Everything got restored.