dockerfile文档编写(2):docker pull、apt install和pip镜像加速
运行给的终端命令
全覆盖法
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://dockerhub.azk8s.cn",
"https://mirror.ccs.tencentyun.com",
"https://registry.cn-hangzhou.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.m.daocloud.io",
"https://noohub.ru",
"https://huecker.io",
"https://dockerhub.timeweb.cloud"
]
}
试了很多办法,还是下载的很慢,突然意识到下载的时候是pip下载,pip也是需要指定镜像源的,dockfile制定了镜像源之后,pull的时候确实很快,但是管不了pip。
file文件中
指定了pip的镜像源,在run指令pip 下载requirements.txt的时候起飞了
RUN pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/simple
指定apt install的镜像源,apt install 起飞
RUN echo "\
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free \n\
deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free \n\
deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free \n\
deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free" > /etc/apt/sources.list