您可以通过修改配置文件 /etc/docker/daemon.json 来使用加速器。如果 SSL 不是合法有效的证书,则必须配置 insecure-registries 跳过证书验证。具体的加速器配置样例如下:
sudo tee /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://docker.{{host}}"],
"insecure-registries": ["docker.{{host}}"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
# 重启 Docker 服务
sudo systemctl daemon-reload && sudo systemctl restart docker
目前支持的平台:
序号 | 源站 | 替换为 | 平台 |
---|---|---|---|
1 | docker.io | docker.{{host}} | Docker Hub |
2 | quay.io | quay.{{host}} | Red Hat |
3 | gcr.io | gcr.{{host}} | |
4 | k8s.gcr.io | k8s-gcr.{{host}} | 旧 Kubernetes |
5 | registry.k8s.io | k8s.{{host}} | 新 Kubernetes |
6 | ghcr.io | ghcr.{{host}} | GitHub |
7 | docker.cloudsmith.io | cloudsmith.{{host}} | Cloudsmith |
8 | public.ecr.aws | ecr.{{host}} | Amazon ECR |
9 | mcr.microsoft.com | mcr.{{host}} | Microsoft |
10 | docker.elastic.co | elastic.{{host}} | Elastic |
11 | nvcr.io | nvcr.{{host}} | NVIDIA |
12 | registry.jujucharms.com | juju.{{host}} | Juju Charms |
13 | cr.l5d.io | l5d.{{host}} | Linkerd |
14 | rocks.canonical.com | rocks.{{host}} | Rocks |
使用示例:
# nginx/nginx-ingress:latest
docker pull docker.{{host}}/nginx/nginx-ingress:latest # 拉取 Docker 官方镜像
docker pull nginx/nginx-ingress:latest # 在 daemon.json 中配置了加速器地址后
# quay.io/coreos/etcd:latest
docker pull quay.{{host}}/coreos/etcd:latest
# gcr.io/google-containers/busybox:latest
docker pull gcr.{{host}}/google-containers/busybox:latest
# k8s.gcr.io/etcd:3.5.7-0
docker pull k8s-gcr.{{host}}/etcd:3.5.7-0
# registry.k8s.io/kube-apiserver:v1.30.0
docker pull k8s.{{host}}/kube-apiserver:v1.30.0
# ghcr.io/openfaas/queue-worker:latest
docker pull ghcr.{{host}}/openfaas/queue-worker:latest
# docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:latest
docker pull cloudsmith.{{host}}/convoy/convoy/frain-dev/convoy:latest
# public.ecr.aws/docker/library/alpine:latest
docker pull ecr.{{host}}/docker/library/alpine:latest
# mcr.microsoft.com/powershell
docker pull mcr.{{host}}/powershell
# docker.elastic.co/elasticsearch/elasticsearch:8.1.0
docker pull elastic.{{host}}/elasticsearch/elasticsearch:8.1.0
# nvcr.io/nvidia/cuda:12.1.0-runtime-ubuntu20.04
docker pull nvcr.{{host}}/nvidia/cuda:12.1.0-runtime-ubuntu20.04
Cloudflare 免费套餐限制每天最多 100,000 个请求,请合理使用此镜像加速器。