Skip to main content

Generate Docker Compose, Traefik, and registry configuration files for multi-registry pull-through caches

Project description

Multi-Registry Pull Through Cache 🚀

Python Docker License Traefik Redis

Generate a complete Docker Compose stack with pull-through caches for multiple container registries, fronted by Traefik and accelerated by Redis.

⚠️ Migrating from the script-based version? See the upgrade guide. TL;DR: python setup.pymulti-registry-cache setup, python generate.pymulti-registry-cache generate. Your existing config.yaml and Docker usage are fully compatible.


flowchart TB
    subgraph Clients
        D[Docker / containerd]
        K[Kubernetes nodes]
    end

    subgraph Cache Stack
        T[Traefik Proxy\nTLS + routing]
        R1[Registry: docker.io]
        R2[Registry: ghcr.io]
        R3[Registry: quay.io]
        RN[Registry: ...]
        RE[Redis\nblob cache]
    end

    subgraph Upstream
        U1[(Docker Hub)]
        U2[(GHCR)]
        U3[(Quay)]
        UN[(...)]
    end

    D & K -->|pull| T
    T --> R1 & R2 & R3 & RN
    R1 & R2 & R3 & RN --> RE
    R1 -.->|cache miss| U1
    R2 -.->|cache miss| U2
    R3 -.->|cache miss| U3
    RN -.->|cache miss| UN

🚀 Features

Feature Description
🏗️ Multi-Registry Mirror Docker Hub, GHCR, Quay, NVCR, or any OCI registry
🔒 Private Registry Add a private registry alongside your caches
🌐 Traefik Proxy Automatic TLS termination and subdomain-based routing
Redis Acceleration Blob descriptor caching for faster repeated pulls
🧙 Interactive Wizard Guided setup command to generate your config.yaml
📦 Installable CLI uvx, pipx, pip install, or Docker — your choice
☸️ K8s Ready Works with k3s, RKE2, containerd, dockerd
🗄️ Flexible Storage Filesystem, S3, GCS, or in-memory backends
🔧 Customizable Full control over Traefik, registry, and Compose config via {name} interpolation
🌱 Eco-Friendly Less external bandwidth = smaller carbon footprint

📦 Installation

With uvx (recommended, zero install)

uvx multi-registry-cache setup
uvx multi-registry-cache generate

With uv tool / pipx

uv tool install multi-registry-cache   # or: pipx install multi-registry-cache
multi-registry-cache setup
multi-registry-cache generate

With pip

pip install multi-registry-cache

With Docker

touch config.yaml
docker run --rm -ti -v "./config.yaml:/app/config.yaml" obeoneorg/multi-registry-cache setup
docker run --rm -ti -v "./config.yaml:/app/config.yaml" -v "./compose:/app/compose" obeoneorg/multi-registry-cache generate

🛠️ Quick Start

flowchart LR
    A["1️⃣ setup"] --> B["2️⃣ edit config"] --> C["3️⃣ generate"] --> D["4️⃣ docker compose up"]

1. Run the interactive wizard

multi-registry-cache setup

2. Review & fine-tune

Edit config.yaml for advanced settings (TLS, Let's Encrypt, storage backends, etc.). See CONFIG.md for details.

3. Generate the stack

multi-registry-cache generate

4. Launch

cd compose && docker compose up -d

⚙️ CLI Reference

Command Description
multi-registry-cache setup Interactive wizard → config.yaml
multi-registry-cache generate Read config.yaml → generate compose/
multi-registry-cache --help Show all commands
Option Applies to Default Description
--config, -c setup, generate config.yaml Config file path
--output-dir, -o generate compose Output directory

🔄 Configuring Container Runtimes

containerd

[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
    endpoint = ["https://dockerhub.registry-cache.example.net"]
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
    endpoint = ["https://ghcr.registry-cache.example.net"]
sudo systemctl restart containerd

nerdctl

mkdir -p /etc/containerd/certs.d/docker.io/

/etc/containerd/certs.d/docker.io/hosts.toml:

server = "https://docker.io"

[host."https://dockerhub.registry-cache.example.net"]
  capabilities = ["pull", "resolve"]

dockerd

{
  "registry-mirrors": ["https://dockerhub.registry-cache.example.net"]
}
sudo systemctl daemon-reload && sudo systemctl restart docker

k3s / RKE2

/etc/rancher/(k3s|rke2)/registries.yaml:

mirrors:
  docker.io:
    endpoint:
      - https://dockerhub.registry-cache.example.net
  ghcr.io:
    endpoint:
      - https://ghcr.registry-cache.example.net

BuildKit

BuildKit resolves images independently from dockerd. Without explicit configuration, docker build will not use your registry mirrors.

Create a buildkitd.toml with your mirrors:

[registry."docker.io"]
  mirrors = ["dockerhub.registry-cache.example.net"]

[registry."ghcr.io"]
  mirrors = ["ghcr.registry-cache.example.net"]

[registry."dockerhub.registry-cache.example.net"]
  http = false
  # ca = ["/etc/certs/my-ca.pem"]  # if using a private CA

[registry."ghcr.registry-cache.example.net"]
  http = false

Where to place this file depends on your setup:

Context Config path
Docker Engine (rootful) /etc/buildkit/buildkitd.toml
Docker Engine (rootless) ~/.config/buildkit/buildkitd.toml
buildx auto-detection ~/.docker/buildx/buildkitd.default.toml
Docker Desktop default builder Not supported (see below)

Docker Desktop: the default builder uses the docker driver, which does not support buildkitd.toml. You must create a separate builder with the docker-container driver:

docker buildx create --use --bootstrap \
  --name cached-builder \
  --driver docker-container \
  --buildkitd-config /path/to/buildkitd.toml

Other Kubernetes distributions

Configure each node's container runtime to use the registry mirror. Refer to your distribution's documentation.


📄 License

MIT — Grégoire Compagnon


Contributions welcome! Open an issue or submit a PR. 🐋

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multi_registry_cache-2.0.0.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multi_registry_cache-2.0.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file multi_registry_cache-2.0.0.tar.gz.

File metadata

  • Download URL: multi_registry_cache-2.0.0.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for multi_registry_cache-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9d275f50ae22dd8c305930b55a04406189f1a9473812353dabc24f628911bea6
MD5 fed7721c83f2550b2aa29986efee4d4a
BLAKE2b-256 de5711a813c11c0d2e6c268f46e56450993604b2bc5ecf653350c6eb95e6c6be

See more details on using hashes here.

File details

Details for the file multi_registry_cache-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for multi_registry_cache-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f30080285aa3a2c3ceeaedc4c8108c25f244e460e35e1262942ec7580c10998c
MD5 c3ea1b1f8eb783bf0592e39505dcb39e
BLAKE2b-256 e54b64bd543b1451b66bf50fd5a3d170becdf8242064f01f8c9952d8e90dcfcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page