柚子快報邀請碼778899分享:容器 運(yùn)維 docker換源
柚子快報邀請碼778899分享:容器 運(yùn)維 docker換源
文章目錄
前言1. 查找可用的鏡像源2. 配置 Docker 鏡像源3. 重啟 Docker 服務(wù)4. 查看dock info是否修改成功5. 驗證鏡像源是否更換成功注意事項
前言
在pull鏡像時遇到如下報錯:
┌──(root?kali)-[/home/longl]
└─# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
c1ec31eb5944: Retrying in 1 second
error pulling image configuration: download failed after attempts=6: dial tcp 173.252.88.67:443: connect: connection refused
解決方法:換源?。。。。。。。?!
1. 查找可用的鏡像源
首先,你需要找到一個可用的鏡像源。一些常見的國內(nèi)鏡像源包括:
阿里云:https://registry.cn-hangzhou.aliyuncs.com騰訊云:https://mirrors.tencent.com/docker華為云:https://mirror.ccs.tencent.com/dockerhub中國科技大學(xué):https://docker.mirrors.ustc.edu.cn/豆瓣(Douban):https://dockerhub.douban.com/
注意阿里云提供: [系統(tǒng)分配前綴].mirror.aliyuncs.com 具體上阿里云容器HUB控制臺查看(需要賬號) 阿里云容器HUB控制臺: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
2. 配置 Docker 鏡像源
Docker 可以通過修改配置文件來更換鏡像源。你可以使用 Docker 提供的 daemon.json 文件來配置鏡像源。
打開或創(chuàng)建 daemon.json 文件。這個文件通常位于 /etc/docker/ 目錄下: 如果沒有創(chuàng)建daemon.json文件就自己創(chuàng)建一下 sudo touch /etc/docker/daemon.json
編輯daemon.json sudo vim /etc/docker/daemon.json
在 daemon.json 文件中添加以下內(nèi)容,將 MIRRORS 替換為你選擇的鏡像源: {
"registry-mirrors": ["https://MIRRORS.mirror.com"]
}
例如,如果你想使用中科大的鏡像源,你應(yīng)該這樣寫: {
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
建議使用阿里的鏡像加速器提供的源 保存并關(guān)閉文件。
3. 重啟 Docker 服務(wù)
配置完成后,需要重啟 Docker 服務(wù)以使配置生效:
sudo systemctl restart docker
4. 查看dock info是否修改成功
如果修改成功,可以在info中查看到修改后的源:
sudo docker info
5. 驗證鏡像源是否更換成功
為了驗證是否成功更換了鏡像源,你可以嘗試?yán)∫粋€鏡像,比如 hello-world:
docker pull hello-world
如果鏡像成功下載,并且過程中沒有出現(xiàn)之前的錯誤,那么更換鏡像源就成功了。
成功?。。?!
┌──(root?kali)-[/etc/docker]
└─# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
┌──(root?kali)-[/etc/docker]
└─# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
注意事項
確保你使用的鏡像源支持你想要拉取的鏡像。有些鏡像源可能需要認(rèn)證,這種情況下你需要在 Docker 的配置中添加認(rèn)證信息。如果你在使用 Docker Compose,你可能還需要配置 .env 文件或 Docker Compose 的配置文件來指定鏡像源。
更換鏡像源是一個常見的操作,特別是在網(wǎng)絡(luò)條件不佳或者需要訪問特定地區(qū)鏡像源的情況下。通過上述步驟,你應(yīng)該能夠順利地更換 Docker 的鏡像源。
柚子快報邀請碼778899分享:容器 運(yùn)維 docker換源
相關(guān)文章
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。