Translate

Dockerfile构建速度过慢,更换国内源方法 (apt / pip)

apt方法:

       在Dockerfile中添加如下两句代码:

RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list

RUN  apt-get clean


/archive.ubuntu.com/        ->        /原本的地址(可以在/etc/apt/sources.list中查看)/




pip方法:

        在Dockerfile中添加:

RUN pip install -U pip

RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple

RUN pip config set install.trusted-host mirrors.aliyun.com


or


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






No comments:

Post a Comment