最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Docker容器內(nèi)更新apt-get國內(nèi)加速實(shí)現(xiàn)過程

 更新時(shí)間:2026年03月01日 10:25:46   作者:Amewin  
文章講述了使用國內(nèi)鏡像加速Docker容器內(nèi)apt-get的方法,通過修改配置文件指向國外鏡像源,解決了網(wǎng)速慢的問題

Docker容器內(nèi)更新源apt-get

由于不使用國內(nèi)鏡像網(wǎng)速緩慢,所以使用國內(nèi)鏡像加速就很必要了,但是經(jīng)過博主測試大部分apt-get加速都是針對Ubuntu 的,根本解決不了Docker 容器內(nèi) apt-get 加速問題。

解決過程

進(jìn)過博主反復(fù)嘗試終于找到了解決方案。

#1.進(jìn)入容器
docker exec -it <容器名稱/id> bash
#2.執(zhí)行命令apt-get update 發(fā)現(xiàn)緩慢
#3.進(jìn)入apt-get 配置目錄
cd /


/apt
#4.執(zhí)行備份命令 --避免修改失敗無法使用
cp sources.list sources.list.bak

#5.同時(shí)執(zhí)行echo下的4行命令,修改成國內(nèi)鏡像源
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

#6.查看文件 是否修改成功
cat sources.list
###############################
root@62be94cc90e7:/etc/apt# cat sources.list

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#
###############################
#7.更新apt-get
apt-get update
#修改完成
#如果發(fā)現(xiàn)安裝vim 緩慢或者失敗,說明本教程不適合你
apt-get install vim
#將備份完成的文件改回來,即可。
rm sources.list
mv sources.list.bak sources.list

說明

修改的原理是使用地址

https://www.debian.org/mirror/list

在別的國家地區(qū)也是可以使用該方法加速,將配置改成所在地區(qū)網(wǎng)址即可。

root@62be94cc90e7:/etc/apt# apt-get update
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.

詳細(xì)文檔(避免新手出錯(cuò))

#進(jìn)入容器
docker exec -it <容器名稱/id> bash
#執(zhí)行命令apt-get 發(fā)現(xiàn)緩慢
apt-get update 
#執(zhí)行命令 Ctrl + C 停止 返回命令行
cd /ect/apt
#查看目錄
ls
root@62be94cc90e7:/etc/apt# ls
apt.conf.d  auth.conf.d  preferences.d  sources.list  sources.list.d  trusted.gpg.d
#執(zhí)行備份命令 --避免修改失敗無法使用,備份可恢復(fù)
cp sources.list sources.list.bak

#執(zhí)行命令 更改apt-get 不用安裝vim (vim真的太慢了)
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
#更改完成后執(zhí)行命令
apt-get update 
#將備份完成的文件改回來,即可。
#rm --刪除文件后使用 mv --更改文件名字
rm sources.list
mv sources.list.bak sources.list

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

武冈市| 来安县| 凭祥市| 香河县| 措美县| 白城市| 东平县| 蒲城县| 通渭县| 伊宁市| 三原县| 北海市| 响水县| 新巴尔虎右旗| 台东市| 大石桥市| 竹溪县| 营口市| 德钦县| 珲春市| 甘谷县| 上犹县| 大理市| 桦川县| 思茅市| 进贤县| 临沧市| 湟源县| 乾安县| 射阳县| 铅山县| 白河县| 临西县| 浑源县| 上杭县| 乾安县| 厦门市| 锡林郭勒盟| 屯昌县| 平邑县| 衡南县|