1、问题描述

  在Docker容器中安装ubuntu镜像之后,默认使用的软件源是ubuntu的官网,速度非常慢,更新软件包经常报错

Docker容器的ubuntu镜像配置apt国内源_docker


  而且初始镜像默认没有安装vim命令,导致修改​​/etc/apt/sources.list​​会很麻烦。

2、解决方案

使用​​sed​​命令进行替换。

sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
apt-get clean
apt-get update

然后速度就起飞了,上面用的是阿里云的镜像,也可以换成其他的镜像源。

Docker容器的ubuntu镜像配置apt国内源_ubuntu_02