(精品)(Docker系列之七)龙芯Fedora21平台上传docker镜像到docker hub

Screenshot-1.png

 申请docker hub 帐号
 
打开 docker hub官网:https://hub.docker.com 进行注册

Screenshot.png

 
邮件激活后登录docker hub 点击 Create --> Create repository 创建一个仓库。
 


Screenshot.png

仓库名称:huangxg20171010/fedora21-base
huangxg20171010是帐号,fedora21-base在docker hub上是Repository,可以理解为镜像名称。
 
在本机登录hub帐号:
# 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: huangxg20171010
Password:
Login Succeeded

 
将本机已经存在的镜像名称做格式化,保证和仓库名称:huangxg20171010/fedora21-base 一致,操作如下:
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fedora21-base 21 65e35642a4da 12 days ago 206.9 MB

# docker tag fedora21-base:21 huangxg20171010/fedora21-base:20170726
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fedora21-base 21 65e35642a4da 12 days ago 206.9 MB
huangxg20171010/fedora21-base 20170726 65e35642a4da 12 days ago 206.9 MB

使用 docker push 将镜像上传至hub上,操作如下:
# docker push huangxg20171010/fedora21-base:20170726
The push refers to a repository [docker.io/huangxg20171010/fedora21-base]
409f8b08daf6: Layer already exists
20170726: digest: sha256:6ec30e213ad3df532c8cad07985c7a522c08e3b1ed7ac491e60156b512484b63 size: 528

 
上传一个tag为latest的镜像,操作如下:
# docker tag fedora21-base:21 huangxg20171010/fedora21-base
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fedora21-base 21 65e35642a4da 12 days ago 206.9 MB
huangxg20171010/fedora21-base 20170726 65e35642a4da 12 days ago 206.9 MB
huangxg20171010/fedora21-base latest 65e35642a4da 12 days ago 206.9 MB

# docker push huangxg20171010/fedora21-base
The push refers to a repository [docker.io/huangxg20171010/fedora21-base]
409f8b08daf6: Layer already exists
latest: digest: sha256:6ec30e213ad3df532c8cad07985c7a522c08e3b1ed7ac491e60156b512484b63 size: 528

 
验证是否可以正常pull镜像,操作如下:
# docker rmi huangxg20171010/fedora21-base
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fedora21-base 21 65e35642a4da 12 days ago 206.9 MB
# docker pull huangxg20171010/fedora21-base
Trying to pull repository docker.io/huangxg20171010/fedora21-base ...
sha256:6ec30e213ad3df532c8cad07985c7a522c08e3b1ed7ac491e60156b512484b63: Pulling from docker.io/huangxg20171010/fedora21-base

Digest: sha256:6ec30e213ad3df532c8cad07985c7a522c08e3b1ed7ac491e60156b512484b63
Status: Downloaded newer image for docker.io/huangxg20171010/fedora21-base

# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fedora21-base 21 65e35642a4da 12 days ago 206.9 MB
huangxg20171010/fedora21-base latest 65e35642a4da 12 days ago 206.9 MB

 
通过docker hub 官网查看验证是否上传成功,操作如下:
  1. 打开 docker hub官网:https://hub.docker.com 登录。 
  2. 如下图所示,点击“DETAILS”。


Screenshot.png

      3. 如下图所示,点击“Tags”,表示两个镜像提交成功,其中一个镜像的tag是20170726,另一个镜像的tag是latest

Screenshot-1.png



总 结
 
按照本文方法,可以将做好的镜像上传至docker hub 上,便于其他宿主机下载使用。

0 个评论

要回复文章请先登录注册