services: registry_proxy: image: registry:2 container_name: registry_proxy ports: - "5000:5000" volumes: - ./config:/etc/docker/registry - ./data:/var/lib/registry environment: # 設定固定的 HTTP secret - REGISTRY_HTTP_SECRET=${REGISTRY_HTTP_SECRET} restart: unless-stopped healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:5000/v2/"] interval: 30s timeout: 10s retries: 3 start_period: 40s # 清理服務 - 定期執行垃圾回收 registry_cleaner: image: registry:2 container_name: registry_cleaner volumes: - ./config:/etc/docker/registry - ./data:/var/lib/registry - ./cleanup.sh:/cleanup.sh:ro environment: - CLEANUP_DAYS_OLD=${CLEANUP_DAYS_OLD} command: /bin/sh -c "while true; do sleep 86400; /cleanup.sh; done" depends_on: - registry_proxy restart: unless-stopped