Skip to content

Instantly share code, notes, and snippets.

@wangjiezhe
Created June 7, 2024 14:00
Show Gist options
  • Save wangjiezhe/3549d45606dff121c8329db57067bcb5 to your computer and use it in GitHub Desktop.
Save wangjiezhe/3549d45606dff121c8329db57067bcb5 to your computer and use it in GitHub Desktop.
Reverse proxy for Docker Hub using docker and caddy.
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
delete:
enabled: true
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
proxy:
remoteurl: https://registry-1.docker.io
version: "3.8"
services:
registry-proxy:
image: registry
restart: unless-stopped
ports:
- 5000:5000
volumes:
- ./data:/var/lib/registry
- ./config.yml:/etc/docker/registry/config.yml
dockerhub.domain.ltd {
# cert setting missing
header Docker-Distribution-Api-Version "registry/2.0"
handle /_ping {
reverse_proxy :5000
}
handle /v2/_ping {
reverse_proxy :5000
}
handle /v2/_catalog {
reverse_proxy :5000
}
handle {
reverse_proxy :5000 {
transport http {
read_timeout 900s
}
}
}
}
[Unit]
Description=Docker Compose Dockerhub Service
Requires=docker.service
After=docker.service
[Service]
# Where the docker-compose file is located
WorkingDirectory=/srv/dockerhub
ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment