docker build打包时下载python包run pip总是超时的解决办法

2023-12-31 16:31:45

报错

Step 4/6 : RUN pip install  -i https://pypi.tuna.tsinghua.edu.cn/simple/  -r requirements.txt
 ---> Running in ece078308279
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f65fc6d4640>, 'Connection to pypi.tuna.tsinghua.edu.cn timed out. (connect timeout=15)')': /simple/

?

解决办法

1、换源。在Dockerfile中修改RUN命令:

RUN pip install  -i https://pypi.tuna.tsinghua.edu.cn/simple/  -r requirements.txt

2、修改运行命令,注意加上--network=host

docker build --network=host -t your-name:tag .

文章来源:https://blog.csdn.net/qq_47677800/article/details/135316668
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。