尽管端口未打开,Docker Swarm 容器仍可访问?

标签 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 没有打开?

最佳答案

Docker 自己设置 iptables 规则,干扰 UFW。
尝试使用附加命令行选项 --iptables=false 运行 docker 守护程序。

关于尽管端口未打开,Docker Swarm 容器仍可访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43962467/

相关文章:

docker - 为生产和开发创建单独的 docker-compose 配置

docker - 如何消除docker中的错误?

docker - 如何防止在 Kubernetes 中由 HPA 创建的特定时间段内新扩展的 pod 缩减?

docker - 无需停机即可更新服务中的图像

Scala,docker - 如何使用 sbt-native-packager 在多模块应用程序中设置 mainClass?

docker - Docker和Cinder,在openstack中可能吗?

node.js - 使用 NginX 在 Digital Ocean 上托管多个 Node.js 应用程序

ruby-on-rails - 无法在 Ubuntu 16.04 上运行 Puma upstart 脚本

python - 无法从同一 docker swarm 上运行的其他服务连接到 postgres 服务?

docker - 所有外部 DNS 查询都在 docker 容器内失败