ubuntu/docker内切换 阿里云软件源

ubuntu/docker内切换 阿里云软件源

此文章适用于ubuntu系统和docker,因为docker内置系统也是ubuntu

1、备份原有源配置文件

镜像源文件在/etc/apt/sources.list

#先创建一个放备份文件的地方,方便发生错误后还原
mkdir /mnt/vdba/backup
mv /etc/apt/sources.list apt-sources-list.ba

2、切换源之前需要先安装一个gpg

因为我是在docker中做的源切换,当换了镜像源后执行apt-get update发现报错 提示我no_pubkey,镜像地址的公钥没有加进去,所以需要加进去,但是添加密钥的时候有提示我如下错误
gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
查找解决方案,发现需要先安装gnupg2

#安装gnupg2
apt-get update && apt-get install -y gnupg2

有的地方网不好,会比较慢。。。。。。这也是我为什么要换镜像源的原因
安装成功后切换源

3、在/etc/apt下编辑sources.list

cat << EOF > /etc/apt/sources.list
#复制如下内容
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 
deb 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 main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse12345678910 
EOF
#回车结束

编辑完成后执行更新命令

#安装公钥
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 9D6D8F6BC857C906
apt-get update
apt update

贼快!!!!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值