Docker学习--Docker仓库之Docker Hub的简单了解

Docker之所以能这么快的火起来,和Docker Hub的作用是分不开的。Docker构建了像GitHub一样的仓库,用来存放大家构建好的Docker镜像,其中已经包括了15000的镜像。大部分需求,都可以通过在Docker Hub中直接下载镜像来实现。

一、注册登录

可以在https://hub.docker.com免费注册一个Docker Hub的账号,在命令行执行docker login,然后根据要求输入用户名和密码来完成登录Docker Hub。登录之后,如果想退出,可以通过docker logout来退出登录。

[root@docker ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: wangchao123
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@docker ~]# docker logout
Removing login credentials for https://index.docker.io/v1/

二、拉取镜像

可以通过docker search命令来查找官方仓库中的镜像,并用docker pull命令来将它下载到本地。

1、搜索镜像
[root@docker ~]# docker search hello-world
NAME                                       DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
hello-world                                Hello World! (an example of minimal Dockeriz…   1094                [OK]                
kitematic/hello-world-nginx                A light-weight nginx container that demonstr…   136                                     
tutum/hello-world                          Image to test docker deployments. Has Apache…   65                                      [OK]
dockercloud/hello-world                    Hello World!                                    17                                      [OK]
crccheck/hello-world                       Hello World web server in under 2.5 MB          11                                      [OK]
vad1mo/hello-world-rest                    A simple REST Service that echoes back all t…   3                                       [OK]
ppc64le/hello-world                        Hello World! (an example of minimal Dockeriz…   2                                       
ansibleplaybookbundle/hello-world-apb      An APB which deploys a sample Hello World! a…   1                                       [OK]
carinamarina/hello-world-app               This is a sample Python web application, run…   1                                       [OK]
markmnei/hello-world-java-docker           Hello-World-Java-docker                         1                                       [OK]
ansibleplaybookbundle/hello-world-db-apb   An APB which deploys a sample Hello World! a…   1                                       [OK]
souravpatnaik/hello-world-go               hello-world in Golang                           1                                       
burdz/hello-world-k8s                      To provide a simple webserver that can have …   0                                       [OK]
datawire/hello-world                       Hello World! Simple Hello World implementati…   0                                       [OK]
koudaiii/hello-world                                                                       0                                       
kevindockercompany/hello-world                                                             0                                       
freddiedevops/hello-world-spring-boot                                                      0                                       
businessgeeks00/hello-world-nodejs                                                         0                                       
uniplaces/hello-world                                                                      0                                       
nirmata/hello-world                                                                        0                                       [OK]
infrastructureascode/hello-world           A tiny "Hello World" web server with a healt…   0                                       [OK]
ansibleplaybookbundle/hello-world          Simple containerized application that tests …   0                                       
s390x/hello-world                          Hello World! (an example of minimal Dockeriz…   0                                       
stumacsolutions/hello-world-container                                                      0                                       
mbrainar/hello-world                       Python-based hello-world web service            0                                       

输出依次为镜像名字、描述、星级(表示该镜像的受欢迎程度)、是否官方创建、是否自动创建。OFFICIAL为OK就是官方镜像。

2、拉取镜像
[root@docker ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
[root@docker ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        12 months ago       1.84kB

三、推送镜像

用户可以在登录成功后通过docker push命令来将自己的镜像推送到Docker Hub中。

修改本地镜像名字为Docker Hub账号名/镜像名

[root@docker ~]# docker tag hello-world wangchao123/hello-world:latest
[root@docker ~]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
hello-world               latest              fce289e99eb9        12 months ago       1.84kB
wangchao123/hello-world   latest              fce289e99eb9        12 months ago       1.84kB

上传镜像到公共仓库

[root@docker ~]# docker push wangchao123/hello-world:latest             
The push refers to repository [docker.io/wangchao123/hello-world]
af0b15c8625b: Mounted from library/hello-world 
latest: digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a size: 524

上传成功之后,查看一下Docker Hub的页面

在这里插入图片描述

好了,上传镜像到Docker Hub就是这么简单。

参考文章:
https://www.cnblogs.com/loveyous/p/11364289.html
http://k8s.unixhot.com/docker/docker-install.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值