docker-compose.yml
```
name: docker-proxy
services:
registry:
image: registry:2
ports:
- '5000:5000'
volumes:
- ./config.yml:/etc/docker/registry/config.yml
- registry_data:/var/lib/registry
restart: always
container_name: registry
hostname: registry
logging:
driver: "json-file"
options:
max-size: "10m"
volumes:
registry_data:
```
config.yml
```
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
proxy:
remoteurl:
http://registry-1.docker.io```
nginx xxx domain.conf
```
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/cert.key;
ssl_trusted_certificate /ssl/origin_ca_rsa_root.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve X25519:P-256:P-384:P-521;
ssl_early_data on;
ssl_stapling on;
ssl_stapling_verify off;
add_header Strict-Transport-Security "max-age=63072000" always;
server_name xxx.domains;
location /v2/ {
# Allow GET, HEAD, OPTIONS requests
if ($request_method !~ ^(GET|HEAD|OPTIONS)$ ) {
return 405; # Method Not Allowed
}
# Proxy requests to the registry
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
listen [::]:80;
server_name xxx.domains;
return 301 https://xxx.domains$request_uri;
}
```
usage:
```
官方镜像
docker pull youdomain/library/postgres:12.22-bookworm
非官方镜像
docker pull youdomain/redis/redis-stack-server
```