大部分Dockerfile都是使用Ubuntu默认源执行apt-update,由于源的问题,生成镜像的过程非常慢。因此,在创建docker容器时,需要将源改为国内镜像。
首先从清华源:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
选择对应Ubuntu版本的源,保存为sources.list存放于Dockerfile相同目录下,然后在Dockerfile文件RUN apt-get update
前加上:
ADD sources.list /etc/apt/
RUN apt-get -y update
若创建docker容器时出现 Certificate verification failed: The certificate is NOT trusted.
将sources.list中的https
改成http
即可。