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
相关推荐
烛衔溟3 小时前
TypeScript 索引签名、只读数组与 keyof / typeof 入门
linux·ubuntu·typescript
良木生香9 小时前
【Linux系统编程】Linux基础指令(1)---一文带你了解Linux的基础指令
linux·运维·服务器·ubuntu·机器学习·系统架构·centos
.柒宇.9 小时前
RedHat10-Ansible部署Docker操作
docker·eureka·ansible
木雷坞10 小时前
内网模型服务启动链路分层实践
docker·容器·gpu
江湖有缘10 小时前
保姆级教程:Docker 部署 Portracker 端口监控工具
jvm·docker·容器
zhangrelay11 小时前
三分钟云课实践速通--C/C++程序设计--
linux·c语言·c++·笔记·学习·ubuntu
lbb 小魔仙12 小时前
Ubuntu 22.04 + Windows 本地部署 AI 大模型完全指南:Ollama + Python 调用实战(附国内加速配置)
人工智能·windows·python·ubuntu
jinanwuhuaguo12 小时前
(第三十六篇)OpenClaw 去中心化的秩序——从“中心调度”到“网格自治”的治理革命
java·大数据·开发语言·网络·docker·去中心化·github
摇滚侠1 天前
Docker 如何查询挂载的目录
运维·docker·容器
萧行之1 天前
Ubuntu+Windows双系统:解决GRUB不显示Windows启动项、一闪而过问题
linux·windows·ubuntu