docker宿主机两台容器间无法通信问题
Posted brownyangyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker宿主机两台容器间无法通信问题相关的知识,希望对你有一定的参考价值。
首先通过docker info查看
[[email protected] mesos-slave]# docker info
Containers: 9
Images: 36
Server Version: 1.9.1
Storage Driver: devicemapper
Pool Name: docker-thinpool
Pool Blocksize: 524.3 kB
Base Device Size: 107.4 GB
Backing Filesystem: xfs
Data file:
Metadata file:
Data Space Used: 5.967 GB
Data Space Total: 510 GB
Data Space Available: 504.1 GB
Metadata Space Used: 2.4 MB
Metadata Space Total: 5.365 GB
Metadata Space Available: 5.362 GB
Udev Sync Supported: true
Deferred Removal Enabled: true
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Library Version: 1.02.146-RHEL7 (2018-01-22)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.5 (Maipo)
CPUs: 64
Total Memory: 503.6 GiB
Name: gx-hps-01
ID: P6IF:SBLW:6KNA:R3DK:ZHK5:4L5V:YQDW:EE5R:RX4Q:34FR:RRGO:3LNS
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
注意上面两个告警
这个告警会导致docker宿主机两台容器间无法通信问题
1.首先用docker exec 进入到同一台宿主机的A容器
2.在容器A中telnet 宿主机IP:B容器在宿主机的映射端口,发现不通
解决办法:
查看bridge-nf-call-iptables当前值
cat /proc/sys/net/bridge/bridge-nf-call-iptables (默认为0)
修改bridge-nf-call-iptables值 (永久生效)
1. 修改 kernel参数
vi /etc/sysctl.conf
2. 加入下面三个参数
net.bridge.bridge-nf-call-iptables = 1
3. 使生效內核参数立即生效
sudo sysctl -p
以上是关于docker宿主机两台容器间无法通信问题的主要内容,如果未能解决你的问题,请参考以下文章
10: docker 跨主机的容器间通信(macvlan / overlay )