虽然端口未打开,Docker Swarm容器是否可以访问?

时间:2017-05-14 09:41:00

标签: docker digital-ocean docker-swarm ufw

我按照这些说明here构建了一个3节点Docker Swarm集群。

一开始我用ufw打开了多个端口,以便在docker节点之间进行通信:

# ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW IN    Anywhere                  
2376/tcp                   ALLOW IN    Anywhere                  
2377/tcp                   ALLOW IN    Anywhere                  
7946/tcp                   ALLOW IN    Anywhere                  
7946/udp                   ALLOW IN    Anywhere                  
4789/udp                   ALLOW IN    Anywhere                  
22/tcp (v6)                ALLOW IN    Anywhere (v6)             
2376/tcp (v6)              ALLOW IN    Anywhere (v6)             
2377/tcp (v6)              ALLOW IN    Anywhere (v6)             
7946/tcp (v6)              ALLOW IN    Anywhere (v6)             
7946/udp (v6)              ALLOW IN    Anywhere (v6)             
4789/udp (v6)              ALLOW IN    Anywhere (v6)

如您所见,端口80 打开。

因此,在本教程结束时,我将官方nginx docker镜像部署到了集群:

docker service create -p 80:80 --name webserver nginx

我能够输入服务器的IP地址,并出现了nginx hello world页面。

现在我想知道,为什么我能够访问网络服务器,虽然端口80没有打开?

1 个答案:

答案 0 :(得分:2)

Docker自行设置iptables规则,干扰UFW 尝试使用附加命令行选项private static IList<Element> OfElementType2(Type elementType) { return new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument) .OfClass(elementType.BaseType) .Where(x => x.GetType() == elementType) .Select(x => ElementSelector.ByElementId(x.Id.IntegerValue)) .ToList(); } 运行docker守护程序。