Docker私有仓库镜像上传下载
创建好私有仓库之后,就可以使用 docker tag 来标记一个镜像,然后推送它到仓库,别的机器上就可以下载下来了。例如私有仓库地址为 192.168.7.26:5000。先在本机查看已有的镜像。$ docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEubuntu latest
·
创建好私有仓库之后,就可以使用 docker tag 来标记一个镜像,然后推送它到仓库,别的机器上就可以下载下来了。例如私有仓库地址为 192.168.7.26:5000。
先在本机查看已有的镜像。
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
使用docker tag 将 ba58 这个镜像标记为 192.168.7.26:5000/test(格式为 docker tag IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG])。
$ docker tag ba58 192.168.7.26:5000/test
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
使用 docker push 上传标记的镜像。
$ docker push 192.168.7.26:5000/test
The push refers to a repository [192.168.7.26:5000/test] (len: 1)
Sending image list
Pushing repository 192.168.7.26:5000/test (1 tags)
Image 511136ea3c5a already pushed, skipping
Image 9bad880da3d2 already pushed, skipping
Image 25f11f5fb0cb already pushed, skipping
Image ebc34468f71d already pushed, skipping
Image 2318d26665ef already pushed, skipping
Image ba5877dc9bec already pushed, skipping
Pushing tag for rev [ba5877dc9bec] on {http://192.168.7.26:5000/v1/repositories/test/tags/latest}
用 curl 查看仓库中的镜像。
$ curl http://192.168.7.26:5000/v1/search
{"num_results": 7, "query": "", "results":
[{"description": "", "name": "library/miaxis_j2ee"},
{"description": "", "name": "library/tomcat"},
{"description": "", "name": "library/ubuntu"},
{"description": "", "name": "library/ubuntu_office"},
{"description": "", "name": "library/desktop_ubu"},
{"description": "", "name": "dockerfile/ubuntu"},
{"description": "", "name": "library/test"}]}
这里可以看到 {"description": "", "name": "library/test"},表明镜像已经被成功上传了。
现在可以到另外一台机器去下载这个镜像。
$ docker pull 192.168.7.26:5000/test
Pulling repository 192.168.7.26:5000/test
ba5877dc9bec: Download complete
511136ea3c5a: Download complete
9bad880da3d2: Download complete
25f11f5fb0cb: Download complete
ebc34468f71d: Download complete
2318d26665ef: Download complete
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
用curl查看仓库的镜像列表
$ curl http://192.168.100.171:5000/v2/_catalog
{"repositories":["docker/myhttpd","docker/mynginx","docker/mysql-master","docker/mysql-slave"]}
用curl查看镜像的tag列表
$ curl http://192.168.100.171:5000/v2/docker/myhttpd/tags/list
{"name":"docker/httpd","tags":["1.0","2.0"]}
先在本机查看已有的镜像。
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
使用docker tag 将 ba58 这个镜像标记为 192.168.7.26:5000/test(格式为 docker tag IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG])。
$ docker tag ba58 192.168.7.26:5000/test
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
使用 docker push 上传标记的镜像。
$ docker push 192.168.7.26:5000/test
The push refers to a repository [192.168.7.26:5000/test] (len: 1)
Sending image list
Pushing repository 192.168.7.26:5000/test (1 tags)
Image 511136ea3c5a already pushed, skipping
Image 9bad880da3d2 already pushed, skipping
Image 25f11f5fb0cb already pushed, skipping
Image ebc34468f71d already pushed, skipping
Image 2318d26665ef already pushed, skipping
Image ba5877dc9bec already pushed, skipping
Pushing tag for rev [ba5877dc9bec] on {http://192.168.7.26:5000/v1/repositories/test/tags/latest}
用 curl 查看仓库中的镜像。
$ curl http://192.168.7.26:5000/v1/search
{"num_results": 7, "query": "", "results":
[{"description": "", "name": "library/miaxis_j2ee"},
{"description": "", "name": "library/tomcat"},
{"description": "", "name": "library/ubuntu"},
{"description": "", "name": "library/ubuntu_office"},
{"description": "", "name": "library/desktop_ubu"},
{"description": "", "name": "dockerfile/ubuntu"},
{"description": "", "name": "library/test"}]}
这里可以看到 {"description": "", "name": "library/test"},表明镜像已经被成功上传了。
现在可以到另外一台机器去下载这个镜像。
$ docker pull 192.168.7.26:5000/test
Pulling repository 192.168.7.26:5000/test
ba5877dc9bec: Download complete
511136ea3c5a: Download complete
9bad880da3d2: Download complete
25f11f5fb0cb: Download complete
ebc34468f71d: Download complete
2318d26665ef: Download complete
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
用curl查看仓库的镜像列表
$ curl http://192.168.100.171:5000/v2/_catalog
{"repositories":["docker/myhttpd","docker/mynginx","docker/mysql-master","docker/mysql-slave"]}
用curl查看镜像的tag列表
$ curl http://192.168.100.171:5000/v2/docker/myhttpd/tags/list
{"name":"docker/httpd","tags":["1.0","2.0"]}
更多推荐
已为社区贡献1条内容
所有评论(0)