Docker registry v3.1 部署

2026-06-24 镜像仓库
  • 4
  • 0
  • 0

新版镜像(v3.1.1)的配置、环境变量等有所调整,如果配置错误会导致registry功能异常,如跨域、密码校验等。

经验证最新版(2026-0624) docker compose 部署方式

docker-compose.yml

networks:
  backend:
    driver: bridge
    name: homelab-backend

services:
  registry:
    image: registry:latest
    container_name: docker-registry
    restart: always
    ports:
      - 5000:5000
    volumes:
      - ./registry/data:/var/lib/registry
      - ./registry/auth:/etc/docker/registry/auth
      - ./registry/certs:/etc/docker/registry/certs
      - ./registry/registry.yml:/etc/distribution/config.yml
    networks:
      - backend
    healthcheck:
      test: [ "CMD", "registry", "garbage-collect", "/etc/docker/registry/config.yml"]
      interval: 600s
      timeout: 30s
      retries: 1
      start_period: 30s


  registry-ui:
    image: joxit/docker-registry-ui:latest
    container_name: registry-ui
    restart: always
    environment:
      - SINGLE_REGISTRY=true
      - NGINX_PROXY_PASS_URL=https://registry:5000
      - DELETE_IMAGES=true
      - REGISTRY_TITLE=Docker Registry UI
      - SHOW_CONTENT_DIGEST=true
      - SHOW_CATALOG_NB_TAGS=true
      - CATALOG_MIN_BRANCHES=1
      - CATALOG_MAX_BRANCHES=1
      - TAGLIST_PAGE_SIZE=100
      - REGISTRY_SECURED=false
      - CATALOG_ELEMENTS_LIMIT=1000
    depends_on:
      - registry
    ports:
      - 8090:80
    networks:
      - backend
    healthcheck:
      test: [ "CMD", "wget", "--spider", "-q", "http://localhost:8080" ]
      interval: 20s
      timeout: 5s
      retries: 10
      start_period: 30s

registry.yml

version: 0.1
log:
  fields:
    service: registry
storage:
  delete:
    enabled: true
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  secret: xxx  # openssl rand -hex 32
  tls:
    certificate: /etc/docker/registry/certs/domain.crt
    key: /etc/docker/registry/certs/domain.key
  headers:
    X-Content-Type-Options: [nosniff]
    Access-Control-Allow-Origin: ['*']
    Access-Control-Allow-Methods: ['HEAD', 'GET', 'OPTIONS', 'DELETE']
    Access-Control-Allow-Headers: ['Authorization', 'Accept']
    Access-Control-Max-Age: [1728000]
    Access-Control-Allow-Credentials: [true]
    Access-Control-Expose-Headers: ['Docker-Content-Digest']
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
auth:
  htpasswd:
    realm: basic-realm
    path: /etc/docker/registry/auth/passwd

宿主机先执行

apt install apache2-utils
htpasswd -Bbn admin 12345678 > ./registry/auth/passwd

参考

  • https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-standalone