国内无法访问 Docker?试试免费的 cf 资源吧。
##直接将代码部署到 Cloudflare Workers,即可通过自定义域名拉取 Docker 镜像。```javascript
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let url = new URL(request.url);
url.hostname = 'registry-1.docker.io';
url.protocol = 'https:';
let headers = new Headers(request.headers);
headers.set('Host', 'registry-1.docker.io');
headers.delete('cf-connecting-ip');
headers.delete('cf-ipcountry');
headers.delete('cf-ray');
headers.delete('cf-visitor');
headers.delete('x-forwarded-proto');
headers.delete('x-forwarded-for');
headers.delete('x-real-ip');
let response = await fetch(url.href, {
method: request.method,
headers: headers,
body: request.body
});
return response;
}
```
例如,将 `docker pull yidadaa/chatgpt-next-web:latest` 改为 `docker pull yourdomain.com/yidadaa/chatgpt-next-web:latest`,即可使用自定义域名拉取镜像。Cloudflare 免费资源足够满足日常需求。
页:
[1]