解决apt-get uqdate太慢的问题
在Dockerfile文件中,我们可以看到有这样的一行代码
RUN apt-get update && \
apt-get install -q -y default-jdk
在部署的过程中,我们发现执行到这段代码的时候,速度变得特别慢,所以我们用下面这个方法去解决速度太慢的问题。
我们在代码前面加上了这几行代码,它们作用是对其进行配源
ADD sources.list /etc/apt/
RUN apt-get clean
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
RUN apt-get update && \
apt-get install -q -y default-jdk
完成上一步骤后,我们在项目目录下需要创建sources.list文件,并写入以下几行代码。
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
以上为阿里源。