docker - 无法访问 docker 容器中的端口
问题描述
我已经发布了从容器到主机的四个端口,但其中只有三个(8080、33099、37017)是可访问的。这是 docker 容器的外观:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cdbc07f875ea test:latest "bash" 35 minutes ago Up 35 minutes 0.0.0.0:8080->8080/tcp, 0.0.0.0:33098-33099->33098-33099/tcp, 0.0.0.0:37017->37017/tcp test1
docker主机上的iptables:
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 172.17.0.0/16 anywhere
MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:37017
MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:33099
MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:33098
MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:http-alt
Chain DOCKER (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere
DNAT tcp -- anywhere anywhere tcp dpt:37017 to:172.17.0.2:37017
DNAT tcp -- anywhere anywhere tcp dpt:33099 to:172.17.0.2:33099
DNAT tcp -- anywhere anywhere tcp dpt:33098 to:172.17.0.2:33098
DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.17.0.2:8080
任何想法,为什么 33098 端口无法访问?
解决方案
推荐阅读
- visual-studio-code - tsserver 日志在哪里?
- delphi - FMX Delphi ComboBox 排序不存在
- javascript - 如何在每个请求中添加延迟
- jmeter - 我可以通过 JMeter 打开 Microsoft EDGE 吗?
- peoplecode - 如何解决“获取数组元素 2:索引不在 1 到 1 范围内”?
- html - 修复 Safari 加载 iframe 放大
- c - 输入错误后程序发疯(C)
- jquery - 使用数据属性作为选择器的最短方法是什么?
- php - 如何使用codeigniter显示mysql数据透视表数据
- json - 如何使用对象映射器快速解析我们解析数组的字典