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
相关推荐
jingshaoqi_ccc2 小时前
ubuntu 24下面安装docker
ubuntu·docker·eureka
TracyCoder1232 小时前
在Ubuntu上搭建大模型最基础的应用环境
linux·运维·ubuntu
关关长语3 小时前
Vue本地部署包快速构建为Docker镜像
前端·vue.js·docker
水滴与鱼3 小时前
DOCKER制作ROS运行的镜像文件
运维·docker·容器
diegoXie5 小时前
WSL2 跨系统文件移动
linux·ubuntu
杨浦老苏6 小时前
安全的消息传递和协作工具Virola Messenger
docker·即时通讯·群晖·im
阿梦Anmory6 小时前
Windows使用wsl教程
ubuntu·wsl
Keine Zeit7 小时前
虚拟机Linux(Ubuntu)忘记登录密码
linux·运维·ubuntu
石像鬼₧魂石7 小时前
Ubuntu 渗透测试步骤
linux·运维·ubuntu
南山星火7 小时前
Ubuntu 22.04 与 24.04 系统常用命令
linux·运维·ubuntu