欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Docker Private Registry搭建(三)

程序员文章站 2022-07-12 17:12:51
...

简介

搭建Docker私服仓库,后端采用ceph swift 分布式存储。使用 Potus 做管理平台. 上文介绍了搭建ceph swift 搭建的详细步骤,本文将介绍 potus 的安装

环境准备:

参考 Docker Private Registry搭建(一)


安装docker

清理yum源
yum clena all

查看版本

yum list docker-engine --showduplicates  

安装docker

yum -y install docker-engine.x86_64 1.12.6-1.el7.centos 

或者直接安装docker:

yum -y install docker

修改docker 配置文件

vi /usr/lib/systemd/system/docker.service    

修改:

ExecStart=/usr/bin/dockerd --insecure-registry 192.168.63.128:5000

安装docker-compose

下载相应的版本(可能需要代理来下载,不要使用pip工具安装,否则可能有问题)

sudo -i
curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

附权限

sudo chmod +x /usr/local/bin/docker-compose

测试

docker-compose --version

参考https://docs.docker.com/compose/install/#install-compose

安装registry

1、准备
创建文件夹:

mkdir -p /root/mydocker
mkdir -p /root/mydocker/compose/registry

2、docker-compose.yml配置:
创建配置文件:

touch /root/mydocker/docker-compose.yml

内容:

registry:
  image: library/registry:2.3.1
  container_name: registry
  volumes:
    - /registry_data
    - ./compose/registry/config.yml:/etc/docker/registry/config.yml:rw
  ports:
    - 5000:5000

特别注意:/etc/docker/registry/config.yml:rw,如果ceph集群模式下这里务必要rw, 否则会报错
permission denied。

新建config.yml,

touch /root/mydocker/compose/registry/config.yml

内容:

version: 0.1
storage:
    swift:
       authurl: http://192.168.63.128:7480/auth/v1
       username: registry:swift
       password: Zu1Qg6anfA9efOQONjDrW8omb7bQ6y2vI1ocDzUb
       container: registry
    cache:
       layerinfo: inmemory
    maintenance:
       uploadpurging:
           enabled: false
    delete:
       enable: true
http:
  addr: 0.0.0.0:5000
health:
    storagedriver:
        enabled: true
        interval: 10s
        threshold: 3

启动registry

nohup docker-compose up

验证

docker pull | tag |push 看是否成功

rados lspools

出现:
rbd
.rgw.root
default.rgw.control
default.rgw.data.root
default.rgw.gc
default.rgw.log
volumes
default.rgw.users.uid
default.rgw.users.keys
default.rgw.meta
default.rgw.users.email
default.rgw.users.swift
default.rgw.buckets.index
default.rgw.buckets.data

rados -p default.rgw.buckets.data ls 

查看是否有镜像存在

radis 配置
镜像的blog信息可以放在redis里面,减少仓库的访问压力。具体配置如下:
docker-compose.yml配置:

registry:
  image: library/registry:2.3.1
  container_name: registry-1
  net: host
  volumes:
    - /registry_data
    - ./compose/registry/config.yml:/etc/docker/registry/config.yml:rw
  ports:
    - 5000:5000

config.yml配置:

version: 0.1
storage:
    swift:
       authurl: http://172.20.16.100:7480/auth/v1
       username: registry:swift
       password: IGEkgZdcl84JPEbaQJMfeDLJ5gdKSezjaCeq9B6z
       container: registry-1
    cache:
       blobdescriptor: redis
    maintenance:
       uploadpurging:
           enabled: false
    delete:
       enable: true
redis:
  addr: 172.20.16.99:6379
  db: 0
  dialtimeout: 100ms
  readtimeout: 100ms
  writetimeout: 100ms
  pool:
    maxidle: 16
    maxactive: 64
    idletimeout: 300s
http:
  addr: 0.0.0.0:5000
health:
    storagedriver:
        enabled: true
        interval: 10s
        threshold: 3


如果使用开源镜像管理平台potus的话,请参考如下配置:

potus安装

下载portus

potus的release版本https://github.com/SUSE/Portus/releases ,当前最新版本为2.2

配置potus
解压potus2.2.tar.gz ,然后进入安装目录。

修改Gemfile

vi Gemfile

https://rubygems.org
修改为
http://rubygems.org

修改compose/registry/config.yml

vim compose/registry/config.yml
storage:
  swift:
    authurl: http://node1:7480/auth/v1
    username: testuser:swift
    password: cIiwW6aoFd9VlqqCU6fLJ1eE2dpY6oe2tIKRVJuy
    container: registry

启动安装
./compose-setup.sh -e node1

安装完成后根据结果提示完成测试,即可。也可参考http://www.dockerinfo.net/879.html

参考:
http://bingdian.blog.51cto.com/94171/1893658
http://www.dockerinfo.net/879.html
https://ivanjobs.github.io/docker-registry-study
https://docs.docker.com/engine/installation/linux/docker-ce/centos/

相关标签: 分布式存储