Docker ubuntu apt-get更换国内源解决Dockerfile构建速度过慢

1. 问题

dockerfile中 使用ubuntu 镜像 执行 RUN apt-get -q update

&& apt-get -q install -y 更新巨慢

2. 解决

使用国内的镜像源即可解决问题,注意如果使用的 包比较冷门 或者国内镜像网站没同步过来 可能就下载不到镜像

在dockerfile中 执行安装包命令 或者 RUN apt-get -q update 之前 增加如下内容

java 复制代码
RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN  apt-get clean

示例

java 复制代码
RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN  apt-get clean

######
# Install common dependencies from packages. Versions here are either
# sufficient or irrelevant.
#
# WARNING: DO NOT PUT JAVA APPS HERE! Otherwise they will install default
# Ubuntu Java.  See Java section below!
######
# hadolint ignore=DL3008
RUN apt-get -q update \
    && apt-get -q install -y --no-install-recommends \
        apt-utils \
        bats \
        build-essential
相关推荐
CheungChunChiu6 分钟前
Linux 总线模型与 bind/unbind 完整解析
linux·ubuntu·sys·bind/unbind
todoitbo2 小时前
openEuler 云原生实战:Docker Compose 部署 Nextcloud 企业级私有云
docker·云原生·容器·openeuler
꧁坚持很酷꧂3 小时前
Ubuntu系统下Qt程序连接串口设备没有问题,但运行时出现Permission denied的解决方法
linux·qt·ubuntu
weixin_46684 小时前
Docker常用命令与操作
运维·docker·容器
The star"'5 小时前
docker swarm和containerd
运维·docker·容器
AL流云。5 小时前
MySQL安装【Centos, Ubuntu, Windows】
mysql·ubuntu·centos
❀͜͡傀儡师5 小时前
Docker部署OneTerm堡垒机
运维·docker·容器·oneterm
飘忽不定的bug5 小时前
记录:ubuntu20.04隐藏鼠标指针
linux·ubuntu
松涛和鸣5 小时前
23、链式栈(LinkStack)的实现与多场景应用
linux·c语言·c++·嵌入式硬件·ubuntu
北珣.5 小时前
docker容器-命令
运维·docker·容器