1 min read

轻量级私有容器镜像仓库

轻量级私有容器镜像仓库

背景

需要一个容器镜像仓库服务,Habor、Nexus是首选,尽量保持轻量化但又想能提供可视化页面。此时就可以使用 registry-ui + docker-registry。

服务实现

  • docker-compose.yml
services:
  registry-ui:
    image: registry.cn-shenzhen.aliyuncs.com/shuhui/docker-registry-ui:2.5.7-debian
    restart: always
    ports:
      - 80:80
    environment:
      - SINGLE_REGISTRY=true
      - REGISTRY_TITLE=Docker Registry UI
      - DELETE_IMAGES=true
      - SHOW_CONTENT_DIGEST=true
      - NGINX_PROXY_PASS_URL=http://registry-server:5000
      - SHOW_CATALOG_NB_TAGS=true
      - CATALOG_MIN_BRANCHES=1
      - CATALOG_MAX_BRANCHES=1
      - TAGLIST_PAGE_SIZE=100
      - REGISTRY_SECURED=false
      - CATALOG_ELEMENTS_LIMIT=1000
    container_name: registry-ui

  registry-server:
    image: registry.cn-shenzhen.aliyuncs.com/shuhui/registry:2.8.3
    restart: always
    environment:
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://xx-hub.vqiu.cn]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Methods: '[HEAD,GET,OPTIONS,DELETE]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Credentials: '[true]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Headers: '[Authorization,Accept,Cache-Control]'
      REGISTRY_HTTP_HEADERS_Access-Control-Expose-Headers: '[Docker-Content-Digest]'
      REGISTRY_STORAGE_DELETE_ENABLED: 'true'
    volumes:
      - /data/registry:/var/lib/registry
    container_name: registry-server
若需要https,新增一个nginx容器服务即可。

截图预览

页面中可以看到仓库中所有的容器镜像

针对某个镜像进行常规操作