dockerRegistry搭建
docker registry安装:
官方仓库下载registry



pull镜像:
fu@ubuntu:~$ sudo docker pull registry

运行镜像 :
sudo docker run -d -p 5000:5000 --restart=always -v /home/registry/data:/tmp/registry-dev --name registry registry:latest

浏览器中查看registry:
返回:{}
返回:{"repositories":[]}
准备一个标准tag,用于上传
sudo docker tag <id> 99fu.cn/fu/registry:latest
如果此时直接push:报错http: server gave HTTP response to HTTPS client
root@ubuntu:/# docker push 192.168.1.110:5000/fu/hello-world
The push refers to a repository [192.168.1.110:5000/fu/hello-world]
Get https://192.168.1.110:5000/v1/_ping: http: server gave HTTP response to HTTPS client
解决以上问题:
新建或者修改daemon.json:
root@ubuntu:/# echo '{ "insecure-registries":["192.168.1.110:5000"] }' > /etc/docker/daemon.json
注: 可以将192.168.1.110:5000 改成 99fu.cn:5000 然后将/etc/hosts 中加入 192.168.1.110 99fu.cn
重启:
root@ubuntu:/# service docker restart
docker stop/waiting
docker start/running, process 3558
root@ubuntu:/# docker push 192.168.1.110:5000/fu/hello-world
The push refers to a repository [192.168.1.110:5000/fu/hello-world]
a02596fdd012: Pushed
latest: digest: sha256:a18ed77532f6d6781500db650194e0f9396ba5f05f8b50d4046b294ae5f83aa4 size: 524
此时,再在浏览器中访问:
返回值:
{"repositories":["fu/hello-world"]}
从别的机器上,上传到registry上:
在 /etc/hosts 中加上 192.168.1.110 99fu.cn
将从官网pull或者自己build的镜像,打上标准的tag
fu@ubuntu:~$ sudo docker tag 285 99fu.cn:5000/centos:centos7.1.1503
fu@ubuntu:~$ sudo docker images
注: 285 为centos镜像的id简写,能区分就行然后 push到registry中
然后浏览器中查看:http://192.168.6.73:5000/v2/_catalog
{"repositories":["centos","fu/centos","fu/hello-world","fu/jdk","fu/jenkins","fu/jre","fu/mysql","fu/registry","registry","ubuntu"]}
利用api访问更多信息:http://blog.csdn.net/ztsinghua/article/details/51496658
如:http://192.168.6.73:5000/v2/fu/registry/tags/list