Docker 配置阿里雲鏡像加速器


由於國內訪問直接訪問docker hub網速比較慢,拉取鏡像的時間就會比較長。一般我們會使用鏡像加速或者直接從國內的一些平台鏡像倉庫上拉取。 

根據網上提供的方案,有網易,daocloud,ustc等解決方案,但是最后還是選擇了阿里雲的。

網易鏡像中心:https://c.163.com/hub#/m/home/ 
daocloud鏡像市場:https://hub.daocloud.io/

 

阿里雲 - 開發者平台:https://dev.aliyun.com/
阿里雲 - 容器Hub服務控制台:https://cr.console.aliyun.com/

注冊並登陸阿里雲 - 開發者平台之后,在首頁點擊“創建我的容器鏡像”,然后就會來到阿里雲的服務面板。點擊加速器標簽。
根據提示輸入Docker登錄時需要使用的密碼(后期可更改),用戶名就是登錄阿里雲的用戶名。
在出現的頁面中,可以得到一個專屬的鏡像加速地址,類似於“https://1234abcd.mirror.aliyuncs.com”。
根據頁面中的“操作文檔”信息,配置自己的Docker加速器。

或者,登錄阿里雲 - 容器Hub服務控制台之后,點擊加速器標簽,也會出現相應信息。

[root@localhost /]# mkdir -p /etc/docker
[root@localhost /]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://tqvgn51t.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://tqvgn53t.mirror.aliyuncs.com"]
}
[root@localhost /]# systemctl daemon-reload
[root@localhost /]# systemctl restart docker

上面命令里面配置的專屬地址是假的,請大家不要照抄。

查看:

[root@localhost hongdada]# docker info
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 3
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: false
 Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: docker-init
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  WARNING: You're not using the default seccomp profile
  Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-693.21.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 975.2 MiB
Name: localhost.localdomain
ID: 2QP3:PYDM:BLLS:P5QS:QGJN:N7GK:DAKV:ZWFG:FW54:FHS4:FCAN:6NR4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://tqvgn51t.mirror.aliyuncs.com
Live Restore Enabled: false
Registries: docker.io (secure)

看看加粗的地方,就是你的阿里雲的專屬加速器地址

從阿里雲拉取,推送鏡像操作:https://cr.console.aliyun.com/?spm=5176.1971733.0.2.MUp3vN#/imageList

登錄阿里雲docker registry:

$ sudo docker login --username=hongda159505@qq.com registry.cn-hangzhou.aliyuncs.com

登錄registry的用戶名是您的阿里雲賬號全名,密碼是您開通服務時設置的密碼。

你可以在鏡像管理首頁點擊右上角按鈕修改docker login密碼。

從registry中拉取鏡像:

$ sudo docker pull registry.cn-hangzhou.aliyuncs.com/hongdada/job1:[鏡像版本號]

將鏡像推送到registry:

$ sudo docker login --username=hongda159505@qq.com registry.cn-hangzhou.aliyuncs.com
$ sudo docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/hongdada/job1:[鏡像版本號]
$ sudo docker push registry.cn-hangzhou.aliyuncs.com/hongdada/job1:[鏡像版本號]

其中[ImageId],[鏡像版本號]請你根據自己的鏡像信息進行填寫。

 

https://blog.csdn.net/u014231523/article/details/61197945

https://ieevee.com/tech/2016/09/28/docker-mirror.html

https://www.jianshu.com/p/1a4025c5f186

https://www.cnblogs.com/anliven/p/6218741.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM