我在Centos 7.9.2009上运行Docker,有一个非常奇怪的问题。容器没有网络访问权限,无法从主机访问。我一直在寻找潜在的解决方案,其中很多似乎都与DNS问题有关(我不认为这里发生了什么,因为甚至在容器中单击8.8.8.8也不起作用)。我试过安装iptables -服务,重新启动iptable& docker的顺序,完全重新启动等等。
为了努力找出问题所在,我在一个单独的终端中运行了tcpdump。一旦我做了,一切都很好!关闭tcpdump进程,它就会停止-没有网络访问。对于为什么运行tcpdump可以解决问题,有什么建议吗?这与tcpdump、监听docker0和建立网络状态有关吗?
启动时tcpdump的输出:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on docker0, link-type EN10MB (Ethernet), capture size 262144 bytes未命名-a的输出:
Linux 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux输出/etc/redhat-释放:
CentOS Linux release 7.9.2009 (Core)ip地址的输出:
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:8b:94:46:19 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:8bff:fe94:4619/64 scope link
valid_lft forever preferred_lft foreveriptables的输出-列表-t nat:
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 !loopback/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 172.17.0.0/16 anywhere
Chain DOCKER (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere码头版本的输出:
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:03:45 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:21 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683提前感谢!
发布于 2020-11-20 14:50:58
https://stackoverflow.com/questions/64921176
复制相似问题