![无法从主机到容器进行通信,反之亦然](https://linux22.com/image/761877/%E6%97%A0%E6%B3%95%E4%BB%8E%E4%B8%BB%E6%9C%BA%E5%88%B0%E5%AE%B9%E5%99%A8%E8%BF%9B%E8%A1%8C%E9%80%9A%E4%BF%A1%EF%BC%8C%E5%8F%8D%E4%B9%8B%E4%BA%A6%E7%84%B6.png)
我有一个在 docker 中运行的 GitLab 实例。但我无法 ping 或 curl 端口 8000。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d31649b89354 gitlab/gitlab-ee:latest "/assets/wrapper" 16 hours ago Up 15 hours (healthy) 0.0.0.0:443->443/tcp, 0.0.0.0:2200->22/tcp, 0.0.0.0:8000->80/tcp gitlab_web_1
docker network inspect bridge
[
{
"Name": "bridge",
"Driver": "bridge",
"EnableIPv6": false,
"Containers": {
"d31649b89354209a33095536f13ac67271d5ebb632a9a2cabf41706036f139ea": {
"Name": "gitlab_web_1",
"EndpointID": "c3c3514a8eb3b9e9d3773debf39f1388179475941e8c5572c98851c3dfe262f3",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
当我尝试 ping 容器时,出现错误。
ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
From 172.17.0.1 icmp_seq=1 Destination Host Unreachable
From 172.17.0.1 icmp_seq=2 Destination Host Unreachable
From 172.17.0.1 icmp_seq=3 Destination Host Unreachable
From 172.17.0.1 icmp_seq=4 Destination Host Unreachable
但如果我运行tcpdump -i docker0
,ping 就会成功运行。