搭建dockerhub加速代理
方案1:使用harbor cache特性代理
参考 链接 搭建harbor服务
使用浏览器登录harbor后,导航到Registries功能新建名为proxy的endpoint,endpoint的配置如下:
Provider:Docker HubName:proxyEndpoint URL:使用默认值Verify Remote Cert:勾选
填写以上的endpoint配置后,点击TEST CONNECTION按钮测试endpoint的连接是否正常(如果能够成功连接Docker Hub则提示成功)。再点击OK按钮保存endpoint信息。
导航到Projects功能新建名为proxy的项目,项目的配置如下:
Project Name:proxyAccess Level:publicProxy Cache:开关打开Endpoint:选择上面创建的endpoint
再点击OK按钮保存。
把代理服务器添加到/etc/docker/daemon.json的insecure-registries配置中。
在没有使用代理的情况下docker pull untergeek/curator:5.7.6拉取镜像失败。
在使用代理的情况下docker pull xxx.xxx.xxx.xxx:80/proxy/untergeek/curator:5.7.6(其中xxx.xxx.xxx.xxx是代理服务器的ip地址或者域名)成功拉取镜像。
方案2:使用registry docker镜像代理
注意:此方案通讯流量没有加密使用一段时间后会被GFW封锁导致不能继续使用。
docker-compose.yaml内容如下:
yaml
version: "3.0"
services:
proxy:
image: registry:2.7.1
environment:
- REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io
- TZ=Asia/Shanghai
command:
- /etc/docker/registry/config.yml
ports:
- '10005:5000'
restart: alwaysdocker客户端/etc/docker/daemon.json配置如下(注意:http://dockerhub.118899.net:10005需要放在https://docker.m.daocloud.io之前,否则不会使用加速代理):
json
{
"registry-mirrors": ["http://dockerhub.xxx.net:10005", "https://docker.m.daocloud.io"],
"insecure-registries": ["http://dockerhub.xxx.net:10005"]
}方案3:配置docker daemon代理
在/etc/docker/daemon.json配置文件中加入如下内容:
json
"proxies": {
"http-proxy": "http://192.168.235.128:1080",
"https-proxy": "http://192.168.235.128:1080",
"no-proxy": "127.0.0.0/8,192.168.1.1/24,192.168.235.1/24,registry.cn-hangzhou.aliyuncs.com"
}- 提醒:以上 registry.cn-hangzhou.aliyuncs.com 可以替换为 *.aliyuncs.com
重启docker daemon
bash
sudo systemctl restart docker方案4:使用cloudflare worker代理
todo