上面的两个小节制作了基础镜像,也使用Dockerfile文件制作了我们需要的镜像,我们可以把自己制作的镜像推送到Docker Hub上,这样就可以直接使用docker pull命令在任意一台主机上pull下来,当然这是一个公共的仓库,别人也可以使用同样的命令下载,如果使用私有的仓库,需要购买。
向Docker Hub上推送必须要在该网站上进行注册,在需要推送的机器上使用下面的命令进行登录。Docker login进行登录:
-
[root@10-10-63-106 ~]# docker login
-
Username: frank
-
Password:
-
Email: XXXX@XXX.com
-
Login Succeeded
登录的认证信息存放在.dockercfg
[root@10-10-63-106 ~]# cat .dockercfg
{"":{"auth":"ZnJhbmt6Zno6NjY0MzUwMTE=","email":"XXXX@XXX.com"}}
推送到Docker Hub上的镜像必须按照下面的格式进行:/,使用docker images命令查看本地的docker镜像,如果当初命名的镜像名字不是按照上面的规则进行的,则可以使用docker tag 添加添加自己的名字。
-
[root@10-10-63-106 ~]# docker images
-
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
-
frankzfz/complie-kernel v1 d157772a9d3c 9 days ago 1.747 GB
-
centos6.3-base latest a8fe6b2d8f23 9 days ago 724.6 MB
-
[root@10-10-63-106 ~]# docker tag centos6.3-base frankzfz/centos6.3-base
-
[root@10-10-63-106 ~]# docker images
-
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
-
frankzfz/complie-kernel v1 d157772a9d3c 9 days ago 1.747 GB
-
centos6.3-base latest a8fe6b2d8f23 9 days ago 724.6 MB
-
frankzfz/centos6.3-base latest a8fe6b2d8f23 9 days ago 724.6 MB
使用docker push进行推送,如果推送成功后,可以看到下面的信息
-
[root@10-10-63-106 ~]# docker push frankzfz/centos6.3-base:latest
-
The push refers to a repository [frankzfz/centos6.3-base] (len: 1)
-
Sending image list
-
Pushing repository frankzfz/centos6.3-base (1 tags)
-
a8fe6b2d8f23: Image already pushed, skipping
-
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上
-
docker push frankzfz/complie-kernel:v1
-
The push refers to a repository [frankzfz/complie-kernel] (len: 1)
-
Sending image list
-
Pushing repository frankzfz/complie-kernel (1 tags)
-
a8fe6b2d8f23: Image already pushed, skipping
-
3317841922a1: Image already pushed, skipping
-
1922df6f140f: Pushing [==================================================>] 652.8 MB/652.8 MB
-
2015/03/11 19:50:38
但是也并没有提示任何的错误信息,推送成功后的正确信息如下:
-
[root@10-10-63-106 ~]# docker push frankzfz/complie-kernel:v1
-
The push refers to a repository [frankzfz/complie-kernel] (len: 1)
-
Sending image list
-
Pushing repository frankzfz/complie-kernel (1 tags)
-
a8fe6b2d8f23: Image already pushed, skipping
-
3317841922a1: Image already pushed, skipping
-
1922df6f140f: Image successfully pushed
-
fb9bd8bb39d0: Image successfully pushed
-
b4657c91837b: Image successfully pushed
-
ac088768389c: Image successfully pushed
-
4cecba576ec9: Image successfully pushed
-
2bba67df2882: Image successfully pushed
-
5c664d95439d: Image successfully pushed
-
a6c6c1776843: Image successfully pushed
-
71c24758ec01: Image successfully pushed
-
b1e1803ae471: Image successfully pushed
-
05ef73a94126: Image successfully pushed
-
3239ca21052e: Image successfully pushed
-
40661c45e523: Image successfully pushed
-
d157772a9d3c: Image successfully pushed
-
Pushing tag for rev [d157772a9d3c] on {https://cdn-registry-1.docker.io/v1/repositories/frankzfz/complie-kernel/tags/v1}
阅读(14680) | 评论(0) | 转发(1) |