1. 程式人生 > >Docker系列~將映象推送到DockerHub(七)

Docker系列~將映象推送到DockerHub(七)

向Docker Hub上推送必須要在該網站上進行註冊,在需要推送的機器上使用下面的命令進行登入。Docker login進行登入:

  1. [[email protected]-10-63-106 ~]# docker login
  2. Username: frank
  3. Password: 
  4. Email: [email protected].com
  5. Login Succeeded

登入的認證資訊存放在.dockercfg

[[email protected] ~]# cat .dockercfg

{"https://index.docker.io/v1/":{"auth":"ZnJhbmt6Zno6NjY0MzUwMTE=","email":"

[email protected]"}}

推送到Docker Hub上的映象必須按照下面的格式進行:/,使用docker images命令檢視本地的docker映象,如果當初命名的映象名字不是按照上面的規則進行的,則可以使用docker tag 新增新增自己的名字。

  1. [[email protected]-10-63-106 ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
  3. frankzfz/complie-kernel v1 d157772a9d3c 9 days ago 1.747 GB
  4. centos6.3-
    base latest a8fe6b2d8f23 9 days ago 724.6 MB
  5. [[email protected]-10-63-106 ~]#docker tag centos6.3-base frankzfz/centos6.3-base
  6. [[email protected]-10-63-106 ~]# docker images
  7. REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
  8. frankzfz/complie-kernel v1 d157772a9d3c 9 days ago 1.747 GB
  9. centos6.3-base latest a8fe6b2d8f23 9 days ago 724.
    6 MB
  10. frankzfz/centos6.3-base latest a8fe6b2d8f23 9 days ago 724.6 MB

使用docker push進行推送,如果推送成功後,可以看到下面的資訊

  1. [[email protected]-10-63-106 ~]# docker push frankzfz/centos6.3-base:latest
  2. The push refers to a repository [frankzfz/centos6.3-base] (len: 1)
  3. Sending image list
  4. Pushing repository frankzfz/centos6.3-base (1 tags)
  5. a8fe6b2d8f23: Image already pushed, skipping 
  6. Pushing tag for rev [a8fe6b2d8f23] on {https://cdn-registry-1.docker.io/v1/repositories/frankzfz/centos6.3-base/tags/latest}
在Docker Hub上也可以看到自己的推送的tag

 上面把基礎映象推送到Docker Hub上,如果是使用Dockerfile進行build的images也可以使用同樣的方法進行推送,但是在推送之前必須把使用該映象的容器stop,然後才能推送成功,一開始沒有停止容器,始終不能成功的把映象推送到Docker Hub上

點選(此處)摺疊或開啟

  1. docker push frankzfz/complie-kernel:v1
  2. The push refers to a repository [frankzfz/complie-kernel] (len: 1)
  3. Sending image list
  4. Pushing repository frankzfz/complie-kernel (1 tags)
  5. a8fe6b2d8f23: Image already pushed, skipping 
  6. 3317841922a1: Image already pushed, skipping 
  7. 1922df6f140f: Pushing [==================================================>] 652.8 MB/652.8 MB
  8. 2015/03/11 19:50:38

但是也並沒有提示任何的錯誤資訊,推送成功後的正確資訊如下:

點選(此處)摺疊或開啟

  1. [[email protected]-10-63-106 ~]# docker push frankzfz/complie-kernel:v1
  2. The push refers to a repository [frankzfz/complie-kernel] (len: 1)
  3. Sending image list
  4. Pushing repository frankzfz/complie-kernel (1 tags)
  5. a8fe6b2d8f23: Image already pushed, skipping 
  6. 3317841922a1: Image already pushed, skipping 
  7. 1922df6f140f: Image successfully pushed 
  8. fb9bd8bb39d0: Image successfully pushed 
  9. b4657c91837b: Image successfully pushed 
  10. ac088768389c: Image successfully pushed 
  11. 4cecba576ec9: Image successfully pushed 
  12. 2bba67df2882: Image successfully pushed 
  13. 5c664d95439d: Image successfully pushed 
  14. a6c6c1776843: Image successfully pushed 
  15. 71c24758ec01: Image successfully pushed 
  16. b1e1803ae471: Image successfully pushed 
  17. 05ef73a94126: Image successfully pushed 
  18. 3239ca21052e: Image successfully pushed 
  19. 40661c45e523: Image successfully pushed 
  20. d157772a9d3c: Image successfully pushed 
  21. Pushing tag for rev [d157772a9d3c] on {https://cdn-registry-1.docker.io/v1/repositories/frankzfz/complie-kernel/tags/v1}