Dockerfile中使用pip镜像源下载速度很慢,如何加速,这里搜索得到自测可行的解决方法
一、问题描述
运行别人的 Dockerfile 时,发现执行 pip3 install ***
时下载很慢
二、解决方法:
在 Dockerfile 的 pip3 install ***
之前的某个位置,增加如下命令:
# 首先需要安装 python3, pip3
RUN apt-get update
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
# 更新pip 至最新
RUN pip3 install pip -U
# 配置阿里源
RUN pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip3 config set install.trusted-host mirrors.aliyun.com
然后重新运行目标 Dockerfile 文件。
参考链接
[1] 铁血使命. Dockerfile中 使用pip镜像源加速下载 [EB/OL]. https://blog.csdn.net/xin_IT_able/article/details/102840470, 2019-10-31/2023-12-19.