我已使用以下命令在一台IP为192.168.XXX.XXX的计算机上设置了docker swarm管理器:
docker swarm初始化--advertise-addr = 192.168.XXX.XXX 我收到了这个消息:
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-
0jpgak7bm7t4mzluz48gdub06f5036q8yaoo99awkjmlz48vtb-
1eutz0k1vp37ztmiuxdnglka2 192.168.XXX.XXX:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
在另一台机器上,我尝试了以下命令:
docker swarm join --token SWMTKN-1-
0jpgak7bm7t4mzluz48gdub06f5036q8yaoo99awkjmlz48vtb-
1eutz0k1vp37ztmiuxdnglka2 192.168.XXX.XXX:2377
结果是:
error response from daemon : rpc error : code = Unavailable desc = all
SubConns are in TransientFailure, latest connection error: connection error
: desc = "transport: Error while dialing dial tcp 192.168.XXX.XXX:2377 :
connect: connection refused
Docker版本:
Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:55:00 2018
OS/Arch: linux/amd64
Experimental: false
答案 0 :(得分:0)
这是您遇到的连接拒绝错误。由于另一台计算机不在同一网络上,因此另一台计算机很可能无法连接到管理器。解决方案:要解决此问题,两台计算机必须能够相互通信。如果这些计算机位于Azure或AWS之类的云中,则创建一个虚拟网络并将两台计算机添加到其中。
调试连接被拒绝错误:
要确认机器无法相互通信,请尝试从另一台机器ping管理器。它很可能在您当前的设置中失败。
$ ping 192.168.XXX.XXX
如果成功,则检查端口2377是否打开并在管理器上侦听。从另一台计算机上运行以下命令:
$ nc -vz 192.168.XXX.XXX 2377
另一个有助于调试的工具是在管理器上运行netstat
:
$ netstat -tuplen
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 101 51772227 -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 25361290 -
tcp6 0 0 :::2377 :::* LISTEN 0 1423965 -
tcp6 0 0 :::7946 :::* LISTEN 0 1423980 -
确认您看到:::2377
和:::7946
,并且它们的状态已设置为LISTEN
,因为docker swarm [1]需要这些端口