Pull-through cache for Docker Hub - avoid rate limits and speed up pulls
1.6K
Pull-through cache for Docker Hub (and other registries). Avoid rate limits, speed up pulls, and save bandwidth across your cluster.
Docker Hub enforces 100 pulls per 6 hours for anonymous users. In a CI/CD pipeline or Kubernetes cluster, you hit this limit constantly. A local cache means each image is pulled from Docker Hub once, then served locally forever.
Real impact:
services:
registry-cache:
image: zachbg/registry-cache:latest
restart: unless-stopped
ports:
- "5000:5000"
volumes:
- registry-data:/var/lib/registry
environment:
CACHE_SIZE: 50g
CACHE_TTL: 168h
volumes:
registry-data:
Then configure Docker daemon (/etc/docker/daemon.json):
{
"registry-mirrors": ["http://localhost:5000"]
}
| Variable | Default | Description |
|---|---|---|
REGISTRY_PROXY_REMOTEURL | https://registry-1.docker.io | Upstream registry URL |
CACHE_SIZE | 50g | Maximum cache size |
CACHE_TTL | 168h | How long to keep cached layers |
DOCKER_HUB_USER | Docker Hub username (for higher limits) | |
DOCKER_HUB_PASSWORD | Docker Hub password/token | |
GC_ENABLED | true | Run periodic garbage collection |
GC_INTERVAL | 86400 | GC interval in seconds (default: 24h) |
environment:
DOCKER_HUB_USER: myuser
DOCKER_HUB_PASSWORD: dckr_pat_xxxxx
environment:
REGISTRY_PROXY_REMOTEURL: https://ghcr.io
environment:
REGISTRY_PROXY_REMOTEURL: https://quay.io
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: registry-cache
spec:
selector:
matchLabels:
app: registry-cache
template:
metadata:
labels:
app: registry-cache
spec:
containers:
- name: cache
image: zachbg/registry-cache:latest
ports:
- containerPort: 5000
hostPort: 5000
volumeMounts:
- name: cache-data
mountPath: /var/lib/registry
volumes:
- name: cache-data
hostPath:
path: /var/cache/docker-registry
| Scenario | Without Cache | With Cache |
|---|---|---|
docker pull nginx (cold) | 2-5s | 2-5s (first time) |
docker pull nginx (warm) | 2-5s | <100ms |
| 10 nodes pulling same image | 10 pulls from Hub | 1 pull from Hub |
| CI with 50 builds/hour | Rate limited | Never limited |
Content type
Image
Digest
sha256:1fd98fd9b…
Size
10.4 MB
Last updated
6 months ago
docker pull zachbg/registry-cache