centos 7 Docker容器启动报WARNING: IPv4 forwarding is disabled. Networking will not work

当使用docker构建容器出现如下报错

Step 7/17 : RUN pip install -r /web/main/requirements.txt
 ---> [Warning] IPv4 forwarding is disabled. Networking will not work.
 ---> Running in 29b30f7d1d4c

解决方案:

vi /etc/sysctl.conf
添加如下代码:
net.ipv4.ip_forward=1(注意除掉行首的#符号)

或者

vi /usr/lib/sysctl.d/00-system.conf
添加如下代码:
net.ipv4.ip_forward=1(注意除掉行首的#符号)

重启network服务

systemctl restart network

查看是否修改成功

sysctl net.ipv4.ip_forward

如果返回为net.ipv4.ip_forward = 1则表示成功了

重新构建容器即可

你可能感兴趣的:(docker)