docker启动的时候提示WARNING: IPv4 forwarding is disabled. Networking will not work.

前言

在启动docker的时候提示警告 WARNING: IPv4 forwarding is disabled. Networking will not work.

# docker run --name eduweb  -dp 8801:8080 edu
WARNING: IPv4 forwarding is disabled. Networking will not work.

设置

sysctl net.ipv4.ip_forward
查看得到的值为0
net.ipv4.ip_forward = 0

修改宿主机的network

1、编辑 vi /etc/sysctl.conf
2、查找net.ipv4.ip_forward,设置为1;如果没有则添加 net.ipv4.ip_forward=1
3、重启network服务 systemctl restart network

查看修改

sysctl net.ipv4.ip_forward
查看得到的值为1
net.ipv4.ip_forward = 1

最后删除容器重新构建,发现该报警消失,而且能在外部访问映射端口。

发布了264 篇原创文章 · 获赞 23 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/Edu_enth/article/details/103732041