溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改

發(fā)布時(shí)間:2022-05-25 15:01:49 來源:億速云 閱讀:613 作者:iii 欄目:大數(shù)據(jù)

這篇文章主要介紹了docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改文章都會有所收獲,下面我們一起來看看吧。

我們可以先查看下自己的鏡像,使用命令:

[root@localhost docker]# docker images
[root@localhost docker]# docker images
repository      tag     image id   created    size
docker.io/nginx    latest    6b914bbcb89e  9 days ago   181.8 mb
hub.c.163.com/library/nginx latest    db079554b4d2  3 weeks ago   181.8 mb
daocloud.io/library/mongo  3.0.14    9fe27000609d  4 weeks ago   269.7 mb
hub.c.163.com/library/mysql latest    7666f75adb6b  5 weeks ago   405.6 mb
hub.c.163.com/library/ubuntu latest    f49eec89601e  6 weeks ago   129.5 mb
hub.c.163.com/library/redis latest    45c3ea2cecac  7 weeks ago   182.9 mb
hub.c.163.com/library/centos latest    c3987965c15d  4 months ago  196.5 mb

然后可以在網(wǎng)易的鏡像中心和daocloud鏡像市場上查詢想要拉取的鏡像。

如圖:網(wǎng)易鏡像

docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改 

docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改

拉取鏡像的命令是:

docker pull 鏡像名字

所以我們可以按照給出的鏡像名字或者命令直接拉取。

[root@localhost docker]# docker pull hub.c.163.com/library/tomcat:latest
trying to pull repository hub.c.163.com/library/tomcat ... 
latest: pulling from hub.c.163.com/library/tomcat
5040bd298390: already exists 
fce5728aad85: pull complete 
c42794440453: pull complete 
9789263043d1: pull complete 
6c6ea13aad15: pull complete 
55336e5423a8: pull complete 
228d33a53bdd: pull complete 
3a1cfabb401c: pull complete 
b5f79327b275: pull complete 
bcbb902619eb: pull complete 
ad3d36b3fbaa: pull complete 
digest: sha256:c3a1781843b319547da95c02c3d4c5a428059702fe17d01005093f4dd4f1b87c
[root@localhost docker]# docker images
repository      tag     image id   created    size
hub.c.163.com/library/tomcat latest    99765a0d7f44  2 weeks ago   355.3 mb

以上是從國內(nèi)鏡像倉庫拉取鏡像的方法。

如果說還是想從dockerhub上拉取,那么使用加速器修改docker的registry-mirrors。我這里使用的是daocloud的加速器。

首先在進(jìn)行注冊登錄。然后點(diǎn)擊加速器。

docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改 

就可以獲取加速器的相關(guān)配置。

docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改 

由于docker的版本不同和操作系統(tǒng)。使用的方法也有差異。我這里使用的是centos7.2和docker1.12的。

使用命令

[root@localhost docker]# docker version
[root@localhost etc]# cat /etc/redhat-release 
centos linux release 7.2.1511 (core)

在使用daocloud加速器時(shí),上面有說明文檔。

所以剛開始我在尋找/etc/default/docker這個(gè)配置文件,一直找不到,后來發(fā)現(xiàn)是因?yàn)橄到y(tǒng)和版本的差異。

在centos7上這個(gè)配置文件已經(jīng)被更改為 /etc/docker/daemon.json

可以在這個(gè)配置中添加相應(yīng)的registry-mirrors路徑

原來是這樣:

[root@localhost docker]# cat daemon.json 
{
 "live-restore": true
}

添加后:

{
 "registry-mirrors": ["http://ef017c13.m.daocloud.io"],
 "live-restore": true
}

可以手動(dòng)vim添加,也可以使用daocloud給出的命令直接更改(建議使用命令)

復(fù)制代碼 代碼如下:


[root@localhost docker]# curl -ssl  | sh -s

更改后重啟docker

service docker restart

然后再拉取鏡像就會發(fā)現(xiàn)速度提高好多。

關(guān)于“docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“docker國內(nèi)鏡像拉取和鏡像加速registry-mirrors怎么配置修改”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI