Docker Hub鏡像公共倉庫使用


              Docker Hub鏡像公共倉庫使用

                                     作者:尹正傑

版權聲明:原創作品,謝絕轉載!否則將追究法律責任。

 

 

 

一.登錄Docker Hub

1>.訪問Docker Hub官網(https://hub.docker.com/)

2>.點擊“Create Repository”(自行注冊一下docker hub官網的id,大約不到2分鍾就能搞定)

3>.填寫創建倉庫的相關信息后,並點擊"Create"

4>.鏡像倉庫創建成功

 

二.上傳鏡像到Docker Hub

1>.在命令中中登錄Docker Hub

[root@docker101.yinzhengjie.org.cn ~]# docker login -u yinzhengjie2019
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@docker101.yinzhengjie.org.cn ~]# 

  如下圖所示,登錄成功可以看到docker的鏡像倉庫地址。

2>.對本地鏡像打tag編號

[root@docker101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY                                                TAG                   IMAGE ID            CREATED             SIZE
centos-haproxy                                            v1.8.20               1858fe05d96f        5 hours ago         606MB
tomcat-app01                                              v0.1                  bf45c22f2d5b        24 hours ago        983MB
tomcat-base                                               8.5.50                9ff79f369094        2 days ago          968MB
jdk-base                                                  1.8.0_231             0f63a97ddc85        2 days ago          953MB
centos-base                                               7.6.1810              b4931fd9ace2        2 days ago          551MB
centos                                                    centos7.6.1810        f1cb7c7d58b7        10 months ago       202MB
registry.cn-beijing.aliyuncs.com/yinzhengjie2020/centos   v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# docker image tag centos:centos7.6.1810 yinzhengjie2019/centos:v0.1_centos7.6.1810
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY                                                TAG                   IMAGE ID            CREATED             SIZE
centos-haproxy                                            v1.8.20               1858fe05d96f        5 hours ago         606MB
tomcat-app01                                              v0.1                  bf45c22f2d5b        24 hours ago        983MB
tomcat-base                                               8.5.50                9ff79f369094        2 days ago          968MB
jdk-base                                                  1.8.0_231             0f63a97ddc85        2 days ago          953MB
centos-base                                               7.6.1810              b4931fd9ace2        2 days ago          551MB
centos                                                    centos7.6.1810        f1cb7c7d58b7        10 months ago       202MB
yinzhengjie2019/centos                                    v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
registry.cn-beijing.aliyuncs.com/yinzhengjie2020/centos   v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# 

 

 3>.將鏡像推送到Docker Hub的Registry

[root@docker101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY                                                TAG                   IMAGE ID            CREATED             SIZE
centos-haproxy                                            v1.8.20               1858fe05d96f        6 hours ago         606MB
tomcat-app01                                              v0.1                  bf45c22f2d5b        24 hours ago        983MB
tomcat-base                                               8.5.50                9ff79f369094        2 days ago          968MB
jdk-base                                                  1.8.0_231             0f63a97ddc85        2 days ago          953MB
centos-base                                               7.6.1810              b4931fd9ace2        2 days ago          551MB
centos                                                    centos7.6.1810        f1cb7c7d58b7        10 months ago       202MB
yinzhengjie2019/centos                                    v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
registry.cn-beijing.aliyuncs.com/yinzhengjie2020/centos   v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# 
[root@docker101.yinzhengjie.org.cn ~]# docker image push yinzhengjie2019/centos:v0.1_centos7.6.1810 
The push refers to repository [docker.io/yinzhengjie2019/centos]
89169d87dbe2: Mounted from library/centos 
v0.1_centos7.6.1810: digest: sha256:747b2de199b6197a26eb1a24d69740d25483995842b2d2f75824095e9d1d19eb size: 529
[root@docker101.yinzhengjie.org.cn ~]# 

 

三.從Docker Hub下載鏡像到本地

[root@docker102.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY                                                TAG                   IMAGE ID            CREATED             SIZE
registry.cn-beijing.aliyuncs.com/yinzhengjie2020/centos   v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
[root@docker102.yinzhengjie.org.cn ~]# 
[root@docker102.yinzhengjie.org.cn ~]# docker image pull yinzhengjie2019/centos:v0.1_centos7.6.1810
v0.1_centos7.6.1810: Pulling from yinzhengjie2019/centos
Digest: sha256:747b2de199b6197a26eb1a24d69740d25483995842b2d2f75824095e9d1d19eb
Status: Downloaded newer image for yinzhengjie2019/centos:v0.1_centos7.6.1810
docker.io/yinzhengjie2019/centos:v0.1_centos7.6.1810
[root@docker102.yinzhengjie.org.cn ~]# 
[root@docker102.yinzhengjie.org.cn ~]# 
[root@docker102.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY                                                TAG                   IMAGE ID            CREATED             SIZE
yinzhengjie2019/centos                                    v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
registry.cn-beijing.aliyuncs.com/yinzhengjie2020/centos   v0.1_centos7.6.1810   f1cb7c7d58b7        10 months ago       202MB
[root@docker102.yinzhengjie.org.cn ~]# 
[root@docker102.yinzhengjie.org.cn ~]# 

 


免責聲明!

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



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