docker debian中apt-get源替换为阿里源

场景

docker容器内安装太慢,实在受不了这速度了。

解决方案

将默认的debian源替换为阿里源。

cat命令(因为默认不带vim)查看源配置文件:

cat /etc/apt/sources.list

默认内容为:

deb http://deb.debian.org/debian jessie main
deb http://deb.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main

只要将 deb.debian.org 替换为 mirrors.aliyun.com 即可,命令如下:

cp /etc/apt/sources.list /etc/apt/sources.list.bak ; # 先备份
echo " " > /etc/apt/sources.list ; # 清空文件
echo "deb http://mirrors.aliyun.com/debian jessie main" >> /etc/apt/sources.list ;
echo "deb http://mirrors.aliyun.com/debian jessie-updates main" >> /etc/apt/sources.list ;
# deb http://security.debian.org jessie/updates main # 这行没啥用,可以不要

执行以下命令进行安装:

apt-get clean;  # 清空缓存
apt-get update;  # 更新
apt-get -y install vim; # -y自动确认,更方便 

是不是速度快多了。

其他源

也有很多人用清华镜像,速度也很不错,可以直接复制到浏览器看看速度:

http://mirrors.aliyun.com/debian   # 阿里源
https://mirrors.ustc.edu.cn/debian  # 清华源
发布了482 篇原创文章 · 获赞 19 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/enthan809882/article/details/104441118