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
相关推荐
青花锁几秒前
Mac电脑安装Docker
macos·docker·容器
Fortune_yangyang9 分钟前
docker 搭建lnmp
运维·docker·容器
howard20059 分钟前
Docker实战:使用CGroups控制资源
docker·cgroups
峰顶听歌的鲸鱼12 分钟前
16.docker:存储
运维·笔记·docker·容器·云计算
无双@20 分钟前
Github BettaFish 微舆docker部署教程 —— 打造你的八卦天团!
docker·容器·开源·github·微舆·bettafish
lxmyzzs34 分钟前
解决Ubuntu中OpenCV报错:Qt平台插件“xcb”加载失败(apt安装方案实测有效)
qt·opencv·ubuntu
winfreedoms39 分钟前
微软商店安装的 WSL Ubuntu如何移动到其他目录下
ubuntu·microsoft·wsl
石像鬼₧魂石10 小时前
HexStrike-AI人工智能 渗透测试学习(Metasploitable2 192.168.1.4)完整流程总结
学习·ubuntu
时光803.10 小时前
快速搭建青龙面板Docker教程
windows·ubuntu·bash·httpx
2301_8000509911 小时前
docker
运维·docker·容器