Docker Swarm 报 Error response from daemon: rpc error: code = 4 desc = context deadline exceeded

问题:

Docker集群重启之后,使用 docker node ls 查看节点时,报 "Error response from daemon: rpc error: code = 4 desc = context deadline exceeded" 的错误。

之前的集群配置如下:

Docker Swarm 报 Error response from daemon: rpc error: code = 4 desc = context deadline exceeded_第1张图片


解决步骤:

1、查看当前docker的输出的日志文件,

Jun 30 10:55:33 Docker1 dockerd-current: time="2018-06-30T10:55:33.788288036+08:00" level=info msg="3a69baa0
23fde4ff became candidate at term 1035"
Jun 30 10:55:33 Docker1 dockerd-current: time="2018-06-30T10:55:33.788299026+08:00" level=info msg="3a69baa0
23fde4ff received vote from 3a69baa023fde4ff at term 1035"
Jun 30 10:55:33 Docker1 dockerd-current: time="2018-06-30T10:55:33.788311909+08:00" level=info msg="3a69baa0
23fde4ff [logterm: 915, index: 114] sent vote request to 49dc57de12cfcd17 at term 1035"
Jun 30 10:55:34 Docker1 dockerd-current: time="2018-06-30T10:55:34.975050529+08:00" level=error msg="agent: 
session failed" error="rpc error: code = 14 desc = grpc: the connection is unavailable" module="node/agent"

Jun 30 10:55:38 Docker1 dockerd-current: time="2018-06-30T10:55:38.788342284+08:00" level=info msg="3a69baa0
23fde4ff is starting a new election at term 1035"

从上面的输出内容可以看出,此时正在进行manager节点的leader选择,因为在多manager node的情况下,需要几个manager node投票产生出leader,此时从加粗的错误内容可以推断出,在与另外一台 manager node 进行通信的时候,由于无法连接到对方2377端口,导致选举失败,那就会导致整个Docker Swarm无法选择出leader,偏偏此集群目前只有两个manager node,那问题就应该出在另外的一台上了。

2、在docker4上查看2377端口开放情况,发现没有任何端口


3、在docker4上开放2377端口


4、在docker1查看swarm node情况

Docker Swarm 报 Error response from daemon: rpc error: code = 4 desc = context deadline exceeded_第2张图片

至此问题解决,也说明一点,如果要使用swarm功能,需要在所有manager node节点上开启2377端口。


你可能感兴趣的:(docker)