Docker容器内修改软件源

该博客介绍了如何在新的Docker容器内,针对不同的Ubuntu版本(如16.04和18.04 LTS)设置阿里云的apt源。首先,通过`cat /etc/issue`检查系统版本,然后根据Ubuntu版本对应的代号(例如16.04对应xenial,18.04对应bionic)更新`/etc/apt/sources.list`文件。提供了一段示例脚本来快速修改和应用镜像源。
摘要由CSDN通过智能技术生成

如果是新的容器的话是没有vim的,所以只能用流来写进去:
但是要注意,用下面的指令查看docker容器中的linux系统版本:

cat /etc/issue

查出自己系统的版本之后,去找对应的开发代号,比如Ubuntu18.04 LTS 对应的开发代号叫Bionic,以下是不同系统版本对应的代号:
在这里插入图片描述
参考链接:Ubuntu 各版本号和名称对照
然后,把自己系统对应的代号在下面修改好之后再运行到容器中,下面给出常用的Ubuntu16和18的例子,其他的要自己修改啦。

Ubuntu16.04 LTS

cat > /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
EOF

Ubuntu18.04 LTS

cat > /etc/apt/sources.list << EOF
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
EOF
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚餐男孩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值