dockerfile构建镜像报错IPv4 forwarding is disabled

时间:2022-07-22
本文章向大家介绍dockerfile构建镜像报错IPv4 forwarding is disabled,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

报错记录:

Step 4/9 : RUN pip3 install -r /var/www/codo-admin/doc/requirements.txt —> [Warning] IPv4 forwarding is disabled. Networking will not work. —> Running in 94e64db68828 Collecting cryptography (from -r /var/www/codo-admin/doc/requirements.txt (line 1)) WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5cb088a470>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/cryptography/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5cb088a898>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/cryptography/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5cb088a6a0>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/cryptography/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5cb088a518>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/cryptography/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5cb088a358>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/cryptography/ ERROR: Could not find a version that satisfies the requirement cryptography (from -r /var/www/codo-admin/doc/requirements.txt (line 1)) (from versions: none) ERROR: No matching distribution found for cryptography (from -r /var/www/codo-admin/doc/requirements.txt (line 1))

这个是由于本地没有开启路由转发的缘故

解决办法:

vim /etc/sysctl.conf
net.ipv4.ip_forward=1   #添加即可

sysctl -p    #使其生效

这样还不行,还需要重启网卡和docker

systemctl restart network
systemctl restart docker

问题解决