分几种不同的情况,不断更新

1、Dockerfile apk add 下载更新软件时,比较慢,如何解决

例子如下:

更好一下仓库
在这里插入图片描述

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

或者改成科大的镜像

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

2、Dockerfilego mod download时,比较慢,如何解决

更新一下代理
如下所示
在这里插入图片描述

ENV GOPROXY https://goproxy.cn

3、Dockerfileaptget 时,比较慢,如何解决

更新一下代理
如下所示

FROM docker.elastic.co/beats-dev/golang-crossbuild:1.16.4-main

#就是这两句,其他忽略
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list

RUN  apt-get clean && apt-get update

RUN apt-get install -y libpcap-dev

4、Ubuntu20:10版本更新源

下面的方法针对是Ubuntu20:10版本

无论你是用Dockerfile还是直接在容器里更新源,
核心的是更新/etc/apt/source.list文件

在这里插入图片描述

可以将下面的语句写到Dockerfile中或者直接在容器里更新

echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy main restricted universe multiverse" > sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-security main restricted universe multiverse" >> sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-updates main restricted universe multiverse" >> sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-backports main restricted universe multiverse" >> sources.list

Dockerfile中案例
在这里插入图片描述

RUN cd /etc/apt && echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy main restricted universe multiverse" > sources.list
RUN cd /etc/apt && echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-security main restricted universe multiverse" >> sources.list
RUN cd /etc/apt && echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-updates main restricted universe multiverse" >> sources.list
RUN cd /etc/apt && echo "deb http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu/ groovy-backports main restricted universe multiverse" >> sources.list

造成此种现象的主要原因是
ubuntu20.10不是LTS长期支持版本,因此现在很多镜像网站中已经去掉了对20.10的支持

5、Ubuntu系统

5.1、备份安装

最好先备份一下

cp /etc/apt/sources.list /etc/apt/sources.list.bak

5.2、Ubuntu22.04系统

5.2.1、更新为 阿里

清空sources.list里的旧内容

echo "" > /etc/apt/sources.list

增加新的阿里内容
vim /etc/apt/sources.list

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

在这里插入图片描述

最后

apt-get update

在这里插入图片描述

5.3、Ubuntu20.04

5.3.1、更新为 阿里

清空sources.list里的旧内容

echo "" > /etc/apt/sources.list

增加新的阿里内容
vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

最后

apt-get update

在这里插入图片描述

5.4、Ubuntu18.04

5.4.1、更新为 阿里源

清空sources.list里的旧内容

echo "" > /etc/apt/sources.list

增加新的阿里源内容
vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

最后

apt-get update

在这里插入图片描述

5.5、Ubuntu16.04

5.5.1、更新为 阿里源

清空sources.list里的旧内容

echo "" > /etc/apt/sources.list

增加新的阿里源内容
vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

最后

apt-get update

在这里插入图片描述






已发表的技术专栏订阅即可观看所有专栏,直接点击题目查看
0  grpcgoprotobuf、multus-cni 技术专栏 总入口


1  grpcgo 源码剖析与实战  文章目录


2  gRPC-go参数功能介绍  专栏目


2  零入门Kubernetes网络实战


4  Protobuf介绍实战 图文专栏  文章目录


5  multus-cni   文章目录(k8s多网络实现方案)


6  grpc、oauth2、openssl双向认证、单向认证专栏文章目录

原文地址:https://blog.csdn.net/u011582922/article/details/130153250

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_11093.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注