最近学习doris,准备在本地使用docker搭建一个环境,doris文档提供Dockfile中有这么一段:
RUN apt-get update && \
apt-get install -y default-mysql-client && \
apt-get clean && \
mkdir /opt/apache-doris && \
cd /opt && \
mv apache-doris-be-1.2.3-bin-x86_64 /opt/apache-doris/be
在docker构建时,上面的命令死活构建不了,问过度娘才知道国内访问debian特别慢,我们可以使用国内的镜像,如阿里就提供了各种各样的镜像
第一步:确定debian的版本,docker构建的时候会有一些地址输出,里面会有stretch、bullseye字样(如下图),这就是版本信息
第二步:打开阿里镜像网站,根据版本确定怎么修改
第三步:在Dockerfile使用sed命令,修改/etc/apt/sources.list,在apt-get命令前添加如下信息
RUN sed -i "1ideb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" /etc/apt/sources.list
RUN sed -i "2ideb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" /etc/apt/sources.list
RUN sed -i "3ideb https://mirrors.aliyun.com/debian-security/ bullseye-security main" /etc/apt/sources.list
RUN sed -i "4ideb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main" /etc/apt/sources.list
RUN sed -i "5ideb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" /etc/apt/sources.list
RUN sed -i "6ideb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" /etc/apt/sources.list
RUN sed -i "7ideb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" /etc/apt/sources.list
RUN sed -i "8ideb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" /etc/apt/sources.list
提示:RUN sed -i "1ixxx" aaa表示 修改aaa文件,在第1行前插入xxx信息,具体自行查看sed命令
修改后的效果如下:
做完上面操作了,我们重新执行docker build,apt-get命令就快多了