域名
哪个快用哪个,建议至少配 2 个做互为备份。注意 hub4 只反代 Docker Hub,其余仓库用 hub1 或 hub3。
hub1.nat.tf 美国 洛杉矶 支持全部仓库
hub3.nat.tf 日本 东京 支持全部仓库
hub4.nat.tf 中国 香港 仅 Docker Hub
使用方法①
docker pull whyour/qinglong:latest
仅需在原命令前缀加入加速镜像地址 例如:
docker pull hub1.nat.tf/whyour/qinglong:latest
使用方法②
registry-mirrors 只对 Docker Hub(docker.io)生效。ghcr、gcr、quay、mcr、nvcr 等不会因为配了镜像加速就变快,仍需在镜像名前显式加前缀,见下方"使用方法③"的对照表。
一键设置镜像加速:修改文件 /etc/docker/daemon.json(如果不存在则创建)
nano /etc/docker/daemon.json
修改JSON文件 更改为以下内容 然后保存
{"registry-mirrors": ["https://hub1.nat.tf", "https://hub3.nat.tf", "https://hub4.nat.tf"]}
保存好之后 执行以下两条命令
sudo systemctl daemon-reload #重载systemd管理守护进程配置文件
sudo systemctl restart docker #重启 Docker 服务
使用方法③
sudo tee /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://hub1.nat.tf", "https://hub3.nat.tf", "https://hub4.nat.tf"]
}
EOF
sudo systemctl daemon-reload && sudo systemctl restart docker
配置后可用以下命令确认 Docker 真的读到了:
docker info --format '{{json .RegistryConfig.Mirrors}}'
使用方法④
原始地址 加速地址
ghcr.io ghcr.hub1.nat.tf
gcr.io gcr.hub1.nat.tf
k8s.gcr.io k8s-gcr.hub1.nat.tf
registry.k8s.io k8s.hub1.nat.tf
quay.io quay.hub1.nat.tf
mcr.microsoft.com mcr.hub1.nat.tf
docker.elastic.co elastic.hub1.nat.tf
nvcr.io nvcr.hub1.nat.tf
例如拉取 ghcr 镜像:
docker pull ghcr.hub1.nat.tf/owner/repo:tag
docker pull mcr.hub3.nat.tf/dotnet/runtime:8.0