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 ~]# 

 

posted @ 2020-01-24 05:52  尹正杰  阅读(4322)  评论(0编辑  收藏  举报