Centos7 使用SSL验证和Nginx做代理搭建Docker仓库Registry
1、安装Docker Registry
2、安装python、pip、htpasswd
3、运行nginx和registry容器,使用docker-compose.yml编排
4、配置nginx
5、加入SSL验证、生成证书等等
6、Docker客户端使用Registry (push/pull)
registry启动后日志里出现如下内容时不用理会
msg="No HTTP secret provided - generated random secret.
This may cause problems with uploads
if multiple registries are behind a load-balancer.
To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable."
go.version=go1.6.3 instance.id=1928af54-0f92-4585-9d2a-cd2982d73e84 version=v2.5.1
http://localhost:5000/v2/
返回{}
当时调试时不能正常返回,后来发现是因为挂载了目录没有权限造成的
需要执行一下命令chcon -Rt svirt_sandbox_file_t /挂载的目录
安装pip,以下链接文档附件里有软件可供下载,从官网上下载太慢了
参考:http://crabdave.iteye.com/blog/2348926
pip下载安装包时发现比较慢,需要修改一下镜像
vi ~/.pip/pip.conf
[global]
timeout = 60
index-url = http://pypi.douban.com/simple
docker-compose 安装会非常慢,耐心等待吧
$ curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
nginx配置时 127.0.0.1 换成0.0.0.0让其它机器也能访问
nginx:
image: "nginx:1.9"
ports:
- 443:443
links:
- registry:registry
volumes:
- ./nginx/:/etc/nginx/conf.d
registry:
image: registry:2
ports:
- 127.0.0.1:5000:5000
environment:
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- ./data:/data
制作证书时使用域名不要使用IP地址,
实验时如果没有域名,查看一下主机的hostname,然后使用即可
查看hostname
more /proc/sys/kernel/hostname
localhost.localdomain
给新增的镜像打个标签:
docker tag debuger localhost.localdomain/debuger:1.0
打标签参考:
http://blog.csdn.net/yangshangwei/article/details/52799675
docker push 之前先登录
$docker login https://localhost.localdomain
Username: docker
Password:
Email:
WARNING: login credentials saved in /root/.docker/config.json Login Succeeded
然后再docker push
网页查看镜像
https://服务地址/v2/_catalog
返回
{"repositories":["debuger"]}
其它的按照以下文档中的详细步骤执行即可
参考文章:http://blog.csdn.net/Tomstrong_369/article/details/51145467
利用阿里云 OSS 搭建私有 Docker 仓库
http://www.open-open.com/lib/view/open1452776342401.html