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
相关推荐
落世繁华10 小时前
DIFY合同生成全流程开发实践(三、后端接口以及优化方向)
docker·一键部署·dify·合同生成·文字转word
LYFlied13 小时前
TypeScript 常见面试问题
ubuntu·面试·typescript
暴躁的菜鸡13 小时前
postgresql16.8二进制包编译
ubuntu·postgresql
wxjlkh13 小时前
docker 搭建 grafana+prometheus 监控主机资源之node_exporter
docker·grafana·prometheus
^乘风破浪^13 小时前
Ubuntu部署Xingrin(星环)企业级漏洞扫描与资产管理平台
linux·运维·ubuntu
꧁坚持很酷꧂14 小时前
把虚拟机Ubuntu中的USB设备名称改为固定名称
linux·数据库·ubuntu
HIT_Weston14 小时前
63、【Ubuntu】【Gitlab】拉出内网 Web 服务:Gitlab 配置审视(七)
前端·ubuntu·gitlab
暴躁的菜鸡14 小时前
Ubuntu22.04安装postgresql16.8
ubuntu·postgresql
Evan芙15 小时前
Nginx 平滑升级
数据库·nginx·ubuntu
杨浦老苏15 小时前
安全共享敏感信息的共享工具Hemmelig.app
docker·群晖·密码·阅后即焚