首先在宿主机外ping 8.8.8.8 发现网络联通,在docker容器内ping则数据包100%丢失。
宿主机外执行
sysctl net.ipv4.ip_forward
结果为0。
永久配置:echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
重启network服务:systemctl restart network
查看编辑结果:sysctl net.ipv4.ip_forward
此时看到结果为1。
后去容器内测试ping正常
首先在宿主机外ping 8.8.8.8 发现网络联通,在docker容器内ping则数据包100%丢失。
宿主机外执行
sysctl net.ipv4.ip_forward
结果为0。
永久配置:echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
重启network服务:systemctl restart network
查看编辑结果:sysctl net.ipv4.ip_forward
此时看到结果为1。
后去容器内测试ping正常
评论区