English | 简体中文
A high-performance Cloudflare Worker / Pages proxy script for various container registries. It supports dynamic routing configuration via Cloudflare KV backend.
- Dynamic Routing: Flexible mapping of domains to upstream registries via Cloudflare KV.
- Multi-Registry Support: Built-in support for Docker Hub, Quay, GCR, GitHub Packages (GHCR), and more.
- Smart Redirection: Automatically handles Docker Hub official image redirections (e.g.,
busybox->library/busybox). - Auth Proxy: Supports Docker Hub credentials to resolve
429 Too Many Requestsrate limiting. - Dual Mode Deployment: Fully supports both Cloudflare Workers and Pages deployment.
Once deployed, simply replace the domain in your docker pull command with your custom domain:
# Original command
docker pull busybox
# Using proxy (assuming your domain is docker.example.com)
docker pull docker.example.com/library/busybox- A Cloudflare account.
- Node.js and npm installed locally.
Make sure you are logged in via wrangler:
npx wrangler loginThe project provides a deploy.sh script to automate KV creation, ID synchronization, and mode switching.
Deploy as Workers:
chmod +x deploy.sh
./deploy.sh -m workersDeploy as Pages:
chmod +x deploy.sh
./deploy.sh -m pagesNote: If you are using a custom config file (e.g., my-config.jsonc), specify it with -c: ./deploy.sh -c my-config.jsonc -m pages.
If you prefer to operate manually, follow these steps:
- Create KV Namespace:
npx wrangler kv namespace create DOCKER_ROUTES
- Update Config: Fill the returned
idinto thekv_namespacessection ofwrangler.jsonc. - Deploy:
- Workers:
npx wrangler deploy - Pages: Manually adjust
wrangler.jsoncand runnpx wrangler pages deploy
- Workers:
Configure routes by adding key-value pairs to the KV namespace.
- Key: Your custom domain (e.g.,
docker.example.com). - Value: Upstream registry URL (e.g.,
https://registry-1.docker.io).
Add via CLI:
npx wrangler kv key put --binding=DOCKER_ROUTES "docker.example.com" "https://registry-1.docker.io"For convenience, the Worker automatically matches the following registries based on the subdomain:
| Subdomain | Upstream Registry |
|---|---|
docker |
https://registry-1.docker.io |
quay |
https://quay.io |
gcr |
https://gcr.io |
k8s-gcr |
https://k8s.gcr.io |
k8s |
https://registry.k8s.io |
ghcr |
https://ghcr.io |
cloudsmith |
https://docker.cloudsmith.io |
ecr |
https://public.ecr.aws |
Configure your own Docker Hub credentials to get higher pull quotas:
-
Create an Access Token in your Docker Hub account settings.
-
Set encrypted secrets:
Workers Mode:
npx wrangler secret put DOCKER_USERNAME npx wrangler secret put DOCKER_PASSWORD
Pages Mode:
npx wrangler pages secret put DOCKER_USERNAME --project-name <YOUR_PROJECT_NAME> npx wrangler pages secret put DOCKER_PASSWORD --project-name <YOUR_PROJECT_NAME>
- Go to Workers & Pages in your Cloudflare dashboard.
- Select your project, go to Settings -> Domains & Routes.
- Click Add Custom Domain to bind your domain.
This project is open-sourced under the Apache-2.0 License.