CentOS 运行 Registry 镜像
1、运行registry镜像
docker run -d -v /opt/lib/registry:/var/lib/registry -p 5000:5000 --restart=always --privileged=true --name registry registry:latest
- -v /opt/lib/registry:/var/lib/registry 默认情况下,会将仓库存放于容器内的 /var/lib/registry 目录下,指定本地目录挂载到容器。
- -p 5000:5000 端口映射
- –restart=always 在容器退出时总是重启容器,主要应用在生产环境
- –privileged=true 在CentOS7中的安全模块selinux把权限禁掉了,参数给容器加特权,不加上传镜像会报权限错误OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’)或者(Received unexpected HTTP status: 500 Internal Server Error)错误
- –name registry 指定容器的名称
2、配置局域网域名
vim /etc/hosts
//添加如下
[局域网IP地址] registry.域名.com
3、每一台rancher的主机,都需要添加hosts,方法如上
4、配置nginx,使registry.域名.com成为https
server {
listen 443 ssl;
server_name registry.域名.com;
ssl_certificate /root/cert/jerry.igoogle.ink.pem;
ssl_certificate_key /root/cert/jerry.igoogle.ink.key;
ssl_session_cache shared:SSL:5m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_pass http://127.0.0.1:5000;
}
}