【docker内linux apt-get换源下载 | 实测可行】apt-get下载提速 | 源自国内阿里源 | docker内apt-get换源

俗话说,脾气再好,也有爆发的时候,,这不,这几天要下载一个包,但是因为之前下载都没换过源,始终用的国外的,小的还行,一旦要下载一个好几个G的包,差点给我急傻了~~~

换源!必须换源!


 步骤:

一、制作一个新的sources.list文件

这里呢,因为我是使用的docker,所以我需要用挂载的方式把一个带有新源的sources.list文件传到我的docker容器里面。

挂载目录:

/home/anaconda/docker_torchserve/model_store: /home/model-server/model-store

 注:用挂载的方式是因我的docker容器没有vim、yum等等。。。

在宿主机的挂载目录下面新建一个 sources.list

 在里面加入如下内容:

deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse

 :wq!  退出,,,

第一步完成!

二、打开docker容器,把挂载的 sources.list 文件 移动到 /etc/apt 目录下面

打开你的容器交互: 

docker exec -it xxx /bin/bash 

cd 到挂载目录下面:(这是我哒,别直接抄上了)

cd /home/model-server/model-store

cp 过去:

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

第二步完成!

三、效果 

可以看到,提高了亿点点速度:

 参考:

Ubuntu使用apt-get下载速度慢的解决方法_无籽西瓜吃吗的博客-CSDN博客_apt-get 太慢

猜你喜欢

转载自blog.csdn.net/m0_61139217/article/details/125708428
今日推荐