您现在的位置是:首页 > 文章详情

docker private registry using rados beckend

日期:2016-01-06点击:586

前提:

docker 下载镜像需要连接到 docker.io, 网络原因, 可能被其他国家限制, 也可能由于网速慢, 会导致异常
因此, 常常需要创建一个私有的 docker private registry 用于保存私有镜像或官方镜像, 提供更加方便快捷的下载方法, 省时省力.

A. 主机说明

主机 ip地址 作用
sh-storage-128204.sh.vclound.com 10.198.128.204 docker registry
sh-storage-128200.sh.vclound.com 10.198.128.200 ceph
sh-storage-128201.sh.vclound.com 10.198.128.201 ceph
sh-storage-128202.sh.vclound.com 10.198.128.202 ceph
sh-storage-128203.sh.vclound.com 10.198.128.203 ceph

B. ceph 重要配置

(ceph 创建过程[略] 请参考之前的 ceph 文档) 

1. 创建 dellpools

ceph osd create pool dellpools 1600 1600

2. ceph 用户授权

第一次授权

ceph auth get-or-create client.docker mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=dockerpools'

假如用户已经存在修改授权方法

ceph auth caps client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=dockerpools, allow rwx pool=cephpools'

3. 导出 keyring

ceph auth export client.docker > /etc/ceph/ceph.client.docker.keyring

C. docker 配置

载入官方 registry 镜像

docker 后端

registry 官方镜像支持多种后端存储,
其中 v1 版本支持 swift, s3, ceph-s3 (radosgw) 等等, 不进行每个详细列举
当前使用的是 v2 版本, 其中对应 ceph 存储的 ceph-s3 接口应该已经不再支持, 如果希望使用 radosgw 方法需要指定 s3 驱动, 另外增加了 volumes (cephfs), rados 模块的支持,
该文档不进行 s3, volumes 测试

镜像

可以利用官方直接下载最新版本的镜像

docker pull registry

载入私有镜像

创建私有镜像的方法参考另外一个文档, 下面 rhel7_7.1.1503.tar, 是我自己创建的私有镜像
常见私有镜像载入前都是 tar 结构
载入私有镜像方法如下

[root@sh-storage-128204 export]# docker load --input rhel7_7.1.1503.tar

查询载入后的镜像

[root@sh-storage-128204 export]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE test 7.1.1503 fab4b1df8eb1 2 days ago 227.6 MB

重命名私有镜像

在上传镜像前, 需要对私有镜像进行 tag 标签

[root@sh-storage-128204 docker]# docker tag fab4b1df8eb1 10.198.128.204:5000/centos:7.1.1503 [root@sh-storage-128204 ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE test 7.1.1503 fab4b1df8eb1 2 days ago 227.6 MB registry 2 b2c682ed7e4c 4 weeks ago 224.5 MB 10.198.128.204:5000/centos 7.1.1503 fab4b1df8eb1 2 days ago 227.6 MB

rados 配置文件

创建 rados.yml 配置

version: 0.1 log: level: debug formatter: text fields: service: registry loglevel: debug storage: rados: poolname: dockerpools username: docker http: addr: :5000 headers: X-Content-Type-Options: [nosniff]

创建 ssl key

在镜像上传时候, 需要调用 ssl key , 否则会遇到 https 连接错误

openssl genrsa -out ca.key 2048 openssl req -new -key ca.key -out docker.csr openssl x509 -req -days 365 -in docker.csr -signkey ca.key -out docker.crt

D. docker 启动

docker -D run -d -p 5000:5000 -e CEPH_CONF=/etc/ceph/ceph.conf -v /var/lib/ceph:/var/lib/ceph -v /etc/ceph:/etc/ceph -v /root/docker/rados.yml:/etc/docker/registry/config.yml -v /etc/docker/certs.d:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker.crt -e REGISTRY_HTTP_TLS_KEY=/certs/ca.key -d registry:2

常见大坑说明

1 registry 镜像无法读取 ceph.conf 配置, 因此需要带参数 -v /etc/ceph:/etc/ceph 2. registry 镜像无法获得 ceph health 状态, 因此需要带参数 -v /var/lib/ceph:/var/lib/ceph 3. 常见 https 连接错误, 由 docker.crt, ca.key 解决 4. 常见 registry 无法连接到 pools, 要么没有授权, 要么无法读取 docker 用户 keyring
原文链接:https://yq.aliyun.com/articles/70830
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章