我有一个混合 Docker Swarm 集群,其中运行着 Linux 机器和 Win7 机器通过 NAT 的 VirtualBox(不允许桥接选项)。
Win7 Win7
| |
(port forwarding on 7946tcp/udp, 2377tcp, 4789udp)
| |
+----+----+ +----+----+ +-------+ +-------+
| VirtBox | | VirtBox | | linux | | linux |
+----+----+ +----+----+ +---+---+ +---+---+
| | | |
+----+---+ +----+---+ +----+---+ +----+---+
| docker | | docker | | docker | | docker |
+----+---+ +----+---+ +----+---+ +----+---+
| | | |
+----+------------+-----------+------------+---+
| docker swarm |
+----------------------------------------------+
Docker swarm 已初始化成功(如下图所示):
docker@frankie:~$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ban0an8sg * Win1 Ready Active Reachable 18.05.0-ce
asdlkj328 Win2 Ready Active Leader 18.05.0-ce
9w05zyye6 Linux1 Ready Active Reachable 18.03.1-ce
slkhj2387 Linux2 Ready Active Reachable 18.03.1-ce
我可以毫无问题地向集群启动服务:
docker@frankie:~$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
9w05zyye6 my-web replicated 1/1 nginx:latest *:8083->80/tcp
很遗憾swarm mesh 只在 Linux 机器之间工作。我可以直接在运行该服务的机器上访问它(即使服务在 Windows 上运行)但网络网格仅在 Linux 之间有效。
accessible on ► | win1 | win2 | lin1 | lin2
running on ▼ +------+------+------+------
win1 | x | | |
win2 | | x | |
linux1 | | | x | x
linux2 | | | x | x
知道问题可能出在哪里吗?
编辑(为澄清起见,添加了端口添加命令):
VBoxManage.exe controlvm "win1" natpf1 "docker-swarm-cluster-management,tcp,0.0.0.0,2377,,2377"
VBoxManage.exe controlvm "win1" natpf1 "docker-swarm-cluster-comm-tcp,tcp,0.0.0.0,7946,,7946"
VBoxManage.exe controlvm "win1" natpf1 "docker-swarm-cluster-comm-udp,udp,0.0.0.0,7946,,7946"
VBoxManage.exe controlvm "win1" natpf1 "docker-swarm-cluster-traffic,udp,0.0.0.0,4789,,4789"