#!/usr/bin/env bash set -euo pipefail listen_ip="${REGISTRY_CACHE_LISTEN_IP:-10.27.27.239}" storage_root="${REGISTRY_CACHE_STORAGE_ROOT:-/var/lib/docker-registry-cache}" if [ "$(id -u)" -ne 0 ]; then echo "Run as root on the Proxmox host." >&2 exit 1 fi apt-get update apt-get install -y docker-registry systemctl disable --now docker-registry.service || true mkdir -p /etc/docker/registry "${storage_root}" chown docker-registry:docker-registry "${storage_root}" cat >/etc/systemd/system/docker-registry-cache@.service <<'UNIT' [Unit] Description=Docker registry pull-through cache for %i After=network.target [Service] User=docker-registry Group=docker-registry ExecStart=/usr/bin/docker-registry serve /etc/docker/registry/cache-%i.yml Restart=on-failure RestartSec=5s [Install] WantedBy=multi-user.target UNIT write_config() { local name="$1" local port="$2" local remote="$3" local dir="${storage_root}/${name}" mkdir -p "${dir}" chown docker-registry:docker-registry "${dir}" cat >"/etc/docker/registry/cache-${name}.yml" <