自建方法
镜像 dockerhub
version: '3.1'
services:
registry:
image: registry:2.8.2
#network_mode: "host"
environment:
REGISTRY_HTTP_ADDR: "0.0.0.0:5000"
REGISTRY_PROXY_REMOTEURL: "https://registry-1.docker.io"
REGISTRY_PROXY_TTL: 168h
HTTPS_PROXY: "http://192.168.25.18:7890"
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- "./registry:/var/lib/registry"
docker-compose -f registry.yml up -d
镜像 quay
类似的原理可以镜像 quay.io
等等:
version: '3.1'
services:
mirror-quay-io:
image: registry:2.8.2
environment:
REGISTRY_HTTP_ADDR: "0.0.0.0:5000"
REGISTRY_PROXY_REMOTEURL: "https://quay.io"
REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED: "true"
REGISTRY_PROXY_TTL: 168h
HTTPS_PROXY: "http://192.168.25.18:8890"
restart: always
ports:
- 5003:5000
volumes:
- "./data/quay.io:/var/lib/registry"
参数说明:
REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED
:开启 schema1 支持,默认关闭REGISTRY_PROXY_REMOTEURL
: 镜像上游地址REGISTRY_PROXY_TTL
: 镜像过期时间客户端用法
正常使用即可:
sudo vim /etc/docker/daemon.json
{
...
"insecure-registries": ["192.168.1.30:5000"],
"registry-mirrors": [
"http://192.168.1.30:5000"
]
...
}
自用镜像
References
- 自建Docker Hub镜像服务
- 自建 Docker Hub 镜像服务
- Distribution Registry - CNCF
- Registry keeps crashing after starting "purgeuploads.go" #4358