构建私有Docker Registry

Posted Edisonxiang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构建私有Docker Registry相关的知识,希望对你有一定的参考价值。

1.设置insecure-registry:

1) sudo vim /etc/default/docker
DOCKER_OPTS="--insecure-registry 10.229.43.237:5000" 

2) $ sudo service docker restart

 

2.设置cert
$ mkdir -p certs && openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/logstash-forwarder.key -x509 -days 365 -out certs/logstash-forwarder.crt

 

3.创建以及检查registry
$ sudo docker run -d -p 5000 --restart=always --name registry -v `pwd`/certs:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/logstash-forwarder.crt -e REGISTRY_HTTP_TLS_KEY=/certs/logstash-forwarder.key registry:2

$ sudo docker ps -a

 

4.拉取images
sudo docker pull hailor/kube-ui:v4
sudo docker pull jetstack/hyperkube:v1.0.6
sudo docker pull ptlange/hyperkube:v1.2.0
sudo docker pull shenshouer/podmaster:1.1
sudo docker pull joltup/podmaster:1.1
sudo docker pull invenfantasy/pause:0.8.0
sudo docker pull shenshouer/pause:0.8.0

也可以手动下载pause,然后load到本地
http://www.sunmite.com/wp-content/uploads/2015/10/pause-0.8.0.tar
docker load --input pause-0.8.0.tar

5.打上标签并上传到registry
sudo docker tag b3822824c727 192.168.98.59:5001/google_containers/kube-ui:v4
sudo docker push 192.168.98.59:5001/google_containers/kube-ui:v4
sudo docker tag 170bb59bf8fa 192.168.98.59:5001/google_containers/hyperkube:v1.0.6
sudo docker push 192.168.98.59:5001/google_containers/hyperkube:v1.0.6
sudo docker tag e49b028d591e 192.168.98.59:5001/google_containers/podmaster:1.1
sudo docker push 192.168.98.59:5001/google_containers/podmaster:1.1
sudo docker tag 91c979809108 192.168.98.59:5001/google_containers/pause:0.8.0
sudo docker push 192.168.98.59:5001/google_containers/pause:0.8.0
sudo docker tag eda6a4884645 192.168.98.77:5001/google_containers/mysql
sudo docker push 192.168.98.77:5001/google_containers/mysql
验证是否上传成功:
sudo docker pull 192.168.98.77:5001/google_containers/kube-ui:v4
sudo docker pull 192.168.98.59:5001/google_containers/hyperkube:v1.0.6
sudo docker pull 192.168.98.59:5001/google_containers/podmaster:1.1
sudo docker pull 192.168.98.59:5001/google_containers/pause:0.8.0
sudo docker pull 192.168.98.77:5001/google_containers/mysql

curl -i -k -v https://edison:[email protected]:5001/v2/_catalog
curl -k https://edison:[email protected]:5001/v2/_catalog
curl -k https://edison:[email protected]:5001/v2/google_containers/kube-ui/tags/list

 

* 获取registry镜像

$ sudo docker pull registry:2.5.1

* 启动registry容器

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

Registry服务默认会将上传的镜像保存在容器的/var/lib/registry,我们将主机的/opt/registry目录挂载到该目录,即可实现将镜像保存到主机的/opt/registry目录。

打开浏览器输入http://127.0.0.1:5000/v2,可以访问说明registry运行正常。

 

以上是关于构建私有Docker Registry的主要内容,如果未能解决你的问题,请参考以下文章

构建Docker私有仓库Gitlab仓库和持续集成环境

Docker 构建私有镜像仓库

企业运维实战--最全Docker学习笔记1.Docker简介安装部署镜像构建Dockerfile详解镜像构建镜像优化本地私有仓库搭建

Docker构建私有仓库

使用Harbor构建docker私有仓库

使用Harbor构建docker私有仓库