dockerfile构建镜像报错IPv4 forwarding is disabled

2020-07-31 15:07:35 浏览数 (1)

报错记录:

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))

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

解决办法:

代码语言:javascript复制
vim /etc/sysctl.conf
net.ipv4.ip_forward=1   #添加即可

sysctl -p    #使其生效

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

代码语言:javascript复制
systemctl restart network
systemctl restart docker

问题解决

0 人点赞