Docker容器内更新源apt-get的方法
由于不使用国内镜像网速缓慢,所以使用国内镜像加速就很必要了,但是经过博主测试大部分apt-get加速都是针对Ubuntu 的,根本解决不了Docker 容器内 apt-get 加速问题。
进过博主反复尝试终于找到了解决方案。
docker exec -it <容器名称/id> bash
cd /ect/apt
cp sources.list sources.list.bak
echo "">sources.list
echo "deb http://ftp2.cn.debian.org/debian/ buster main">>sources.list
echo "deb http://ftp2.cn.debian.org/debian/debian-security buster/updates main">>sources.list
echo "deb http://ftp2.cn.debian.org/debian/debian buster-updates main">>sources.list
cat sources.list
root@62be94cc90e7:/etc/apt
deb http://ftp2.cn.debian.org/debian/ buster main
deb http://ftp2.cn.debian.org/debian/debian-security buster/updates main
deb http://ftp2.cn.debian.org/debian/debian buster-updates main
root@62be94cc90e7:/etc/apt
apt-get update
apt-get install vim
rm sources.list
mv sources.list.bak sources.list
说明
修改的原理是使用【地址】
https://www.debian.org/mirror/list
在别的国家地区也是可以使用该方法加速,将配置改成所在地区网址即可。
root@62be94cc90e7:/etc/apt
Get:1 http://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease [122 kB]
Ign:2 http://mirrors.tuna.tsinghua.edu.cn/debian/debian-security buster/updates InRelease
Ign:3 http://mirrors.tuna.tsinghua.edu.cn/debian/debian buster-updates InRelease
Err:4 http://mirrors.tuna.tsinghua.edu.cn/debian/debian-security buster/updates Release
404 Not Found [IP: 101.6.8.193 80]
Get:6 http://mirrors.tuna.tsinghua.edu.cn/debian buster/main amd64 Packages [7906 kB]
Err:5 http://mirrors.tuna.tsinghua.edu.cn/debian/debian buster-updates Release
404 Not Found [IP: 101.6.8.193 80]
Reading package lists... Done
E: The repository 'http://ftp2.cn.debian.org/debian/debian-security buster/updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://ftp2.cn.debian.org/debian/debian buster-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
详细文档(避免新手出错)
docker exec -it <容器名称/id> bash
apt-get update
cd /ect/apt
ls
root@62be94cc90e7:/etc/apt
apt.conf.d auth.conf.d preferences.d sources.list sources.list.d trusted.gpg.d
cp sources.list sources.list.bak
echo "">sources.list
echo "deb http://ftp2.cn.debian.org/debian/ buster main">>sources.list
echo "deb http://ftp2.cn.debian.org/debian/debian-security buster/updates main">>sources.list
echo "deb http://ftp2.cn.debian.org/debian/debian buster-updates main">>sources.list
apt-get update
rm sources.list
mv sources.list.bak sources.list
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)