码迷,mamicode.com
首页 > 其他好文 > 详细

Docker入门与应用系列(六)Docker私有与公共镜像仓库

时间:2017-12-17 10:55:57      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:rom   rar   .com   emc   mon   png   use   emctl   adb   

1.搭建私有镜像仓库
Docker Hub作为Docker默认官方公共镜像;
如果想搭建自己的私有镜像仓库,官方提供registry镜像,使搭建私有仓库非常简单
1.1.1下载registry镜像并启动

docker pull registry
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry

1.1.2 测试,查看镜像仓库中所有的镜像

root@linux-node3:~# curl http://192.168.1.82:5000/v2/_catalog
{"repositories":[]}

1.2 私有仓库管理
1.2.1 配置私有仓库可信任

root@linux-node3:~# cat /etc/docker/daemon.json #需要创建此文件
{ "insecure-registries":["192.168.1.82:5000"] }
root@linux-node3:~# systemctl restart docker

1.2.2 打标签

root@linux-node3:~# docker tag centos:6 192.168.1.82:5000/centos:6
root@linux-node3:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 177391bcf802 2 weeks ago 33.3MB
192.168.1.82:5000/centos 6 df3764b1d215 2 weeks ago 194MB
centos 6 df3764b1d215 2 weeks ago 194MB

1.2.3 上传镜像

root@linux-node3:~# docker push 192.168.1.82:5000/centos:6
The push refers to a repository [192.168.1.82:5000/centos]
13d6d4fbf536: Pushed 
6: digest: sha256:82adb6d4b857ffd254af8041957df8481c84a9a1b9fdcc6efc4ba6432b1d6940 size: 529
root@linux-node3:~# curl http://192.168.1.82:5000/v2/_catalog
{"repositories":["centos"]}

1.2.4 下载镜像

root@linux-node3:~# docker pull 192.168.1.82:5000/centos:6
6: Pulling from centos
Digest: sha256:82adb6d4b857ffd254af8041957df8481c84a9a1b9fdcc6efc4ba6432b1d6940
Status: Image is up to date for 192.168.1.82:5000/centos:6

1.2.5 列出仓库镜像标签

root@linux-node3:~# curl http://192.168.1.82:5000/v2/centos/tags/list
{"name":"centos","tags":["6"]}

 2.公共仓库
2.1 注册账号
https://hub.docker.com
2.2 登陆Docker hub

[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you dont have a Docker ID, head over to https://hub.docker.com to create one.
Username: syavingc
Password: 
Login Succeeded

docker login --username-syavingc --password=123456

2.3 镜像打标签

docker tag centos:6 syavingc/centos:6

2.4 上传

root@linux-node3:~# docker push syavingc/centos:6
The push refers to a repository [docker.io/syavingc/centos]
6c44122e3bf1: Pushed 
bd020e07e375: Pushed 
51f0477e960f: Pushed 
cf80bccaefdb: Pushed 
f413106c0a75: Pushed 
13d6d4fbf536: Mounted from library/centos 
6: digest: sha256:e9c108ce15700392f101e950d8138d3becf534f5179f0432a7c2c56f56507e88 size: 1576

技术分享图片

#搜索测试

dicker search syavingc

2.5 下载

docker pull syavingc/cenots:6

 

Docker入门与应用系列(六)Docker私有与公共镜像仓库

标签:rom   rar   .com   emc   mon   png   use   emctl   adb   

原文地址:http://www.cnblogs.com/syaving/p/8048309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!