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
相关推荐
IT_Octopus8 小时前
triton backend 模式docker 部署 pytorch gpu模型 镜像选择
pytorch·docker·triton·模型推理
ximy13359 小时前
AI服务器工作之ubuntu系统下的驱动安装
运维·服务器·ubuntu
wudl556610 小时前
Docker 常用命令
docker·容器·eureka
选与握11 小时前
ubuntu22 docker安装ros1 noetic
docker·ros1
wuyunhang12345611 小时前
Docker----快速入门
docker·容器·架构
liliangcsdn12 小时前
docker环境如何基于python操作mysql关系数据库
docker·容器
Warren9813 小时前
复习MySQL
数据库·windows·tcp/ip·mysql·ubuntu·ssh·ansible
java_logo13 小时前
Docker 部署微服务项目保姆级教程
java·运维·docker·微服务·容器·eureka·架构
森G14 小时前
2六Ubuntu文件系统移植
linux·ubuntu
冲上云霄的Jayden15 小时前
修改 Docker 容器中 MySQL 8.0 默认编码为 utf8mb4_unicode_ci
utf-8·mysql·ci/cd·docker·utf8mb4