Docker registry + Ceph存储

Docker registry + Ceph存储

环境:centos 7.2 64bit
1,安装docker-registry

yum install docker-registry

2,配置/etc/sysconfig/docker-registry

# The Docker registry configuration file
DOCKER_REGISTRY_CONFIG=/etc/docker-registry.yml

# The configuration to use from DOCKER_REGISTRY_CONFIG file
SETTINGS_FLAVOR=ceph-s3

# Address to bind the registry to
REGISTRY_ADDRESS=0.0.0.0

# Port to bind the registry to
REGISTRY_PORT=5000

# Number of workers to handle the connections
GUNICORN_WORKERS=4

3,修改/etc/docker-registry.yml,ceph-s3部分

ceph-s3: &ceph-s3
    <<: *common
    storage: s3
    s3_region: ~
    s3_bucket: _env:AWS_BUCKET
    s3_encrypt: _env:AWS_ENCRYPT:false
    s3_secure: _env:AWS_SECURE:false
    storage_path: _env:STORAGE_PATH:/registry
    s3_access_key: _env:AWS_KEY:myid
    s3_secret_key: _env:AWS_SECRET:mypasswd
    boto_bucket: _env:AWS_BUCKET:dockerimages
    boto_host: _env:AWS_HOST:oss.myceph.com
    boto_port: _env:AWS_PORT:80
    boto_debug: _env:AWS_DEBUG:0
    boto_calling_format: _env:AWS_CALLING_FORMAT:boto.s3.connection.OrdinaryCallingFormat

4,重启docker-registry服务

service docker-registry restart

5,使用cache可提升仓库访问性能,需要修改/etc/docker-registry.yml,重启docker-registry服务生效。

    cache:
        host: _env:CACHE_REDIS_HOST:myredis.com
        port: _env:CACHE_REDIS_PORT:5898
        db: _env:CACHE_REDIS_DB:0
        password: _env:CACHE_REDIS_PASSWORD:myredispasswd

    # Enabling LRU cache for small files
    # This speeds up read/write on small files
    # when using a remote storage backend (like S3).
    cache_lru:
        host: _env:CACHE_LRU_REDIS_HOST:myredis.com
        port: _env:CACHE_LRU_REDIS_PORT:5898
        db: _env:CACHE_LRU_REDIS_DB:0
        password: _env:CACHE_LRU_REDIS_PASSWORD:myredispasswd

注意:
在centos6.6环境下配置ceph-s3存储,重启docker-registry服务,如果有报错:

DNSError: [Errno 3] name does not exist

此时修改/usr/lib/python2.6/site-packages/docker-registry/docker_registry/drivers/s3.py,在Storage._build_connection_params方法内增加kwargs[‘calling_format’] = self._config.boto_calling_format


class Storage(coreboto.Base):

    def __init__(self, path, config):
        super(Storage, self).__init__(path, config)

    def _build_connection_params(self):
        kwargs = super(Storage, self)._build_connection_params()
        if self._config.s3_secure is not None:
            kwargs['is_secure'] = (self._config.s3_secure is True)
        kwargs['calling_format'] = self._config.boto_calling_format
        return kwargs

你可能感兴趣的:(Docker)