安装 docker registry

docker-compose.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
services:
registry:
image: registry:2.8.3
container_name: registry
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- "${COMPOSE_DATA_DIR:-/data}/registry:/var/lib/registry"
ports:
- "5000:5000"

registry-ui:
image: joxit/docker-registry-ui:2.5.7
container_name: registry-ui
restart: always
depends_on:
- registry
environment:
- TZ=Asia/Shanghai
- SINGLE_REGISTRY=true
- SHOW_CONTENT_DIGEST=true
- PULL_URL=http://hub.starudream.local
- NGINX_PROXY_PASS_URL=http://registry:5000
ports:
#- "80:80"
- "5001:80"

registry-ui 默认附带一个 nginx,反向代理了 registry,如果没有其他网关可以设置为 80 端口直接使用。

nginx 反代配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
http {
server {
listen 8080;

location /v2/ {
proxy_pass http://10.252.25.215:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /registry/ {
proxy_pass http://10.252.25.215:5001/;
}
}
}