Pull container images through a mirror容器镜像加速
Docker Hub, gcr.io, ghcr.io, registry.k8s.io and quay.io, through mirror addresses on this site. Pull only: no push, search or catalog. Images pulled once are cached here, so later pulls are fast.Nothing is stored here: every pull passes straight through.Docker Hub、gcr.io、ghcr.io、registry.k8s.io 和 quay.io 的镜像,经由本站的加速地址拉取。只支持拉取,不支持推送、搜索和列出仓库。拉取过的镜像缓存在本站,再拉更快。本站不保存镜像,每次拉取都直接转发。
Get started开始使用
Point your container runtime at the mirror once; pulls then go through this site without changing a single image name.给容器运行时配置一次镜像加速,之后拉取会自动经过本站,镜像名一个字都不用改。
The mirror addresses are placeholders加速地址是占位符
This page could not work out the mirror addresses from its own address (opened by IP or localhost, say), so docker.<your-domain> stands in for them. Set domains in web/site.json when deploying.没能从当前地址推导出加速域名(例如用 IP 或 localhost 访问),下面用 docker.<你的域名> 占位。部署时可以在 web/site.json 的 domains 里配置。
DockerDocker
-
Add the mirror to the Docker daemon给 Docker 守护进程加上镜像加速
In
/etc/docker/daemon.json. If the file has content already, mergeregistry-mirrorsinto it instead of replacing it.编辑/etc/docker/daemon.json。文件里已有内容时,把registry-mirrors合并进去,不要整体覆盖。/etc/docker/daemon.json{ "registry-mirrors": ["https://docker.<your-domain><你的域名>"] }Only the Docker Hub mirror goes here这里只填 Docker Hub 的加速地址
The other addresses mirror other registries. Listed in
registry-mirrors, they make Docker try each of them first, and fail, on every Docker Hub pull.其他地址加速的是别的仓库。写进registry-mirrors后,每次拉取 Docker Hub 的镜像,Docker 都会先在它们上面各试一次、失败一次。 -
Restart Docker重启 Docker
Running containers restart with it, unless
live-restoreis on.正在运行的容器会跟着重启,除非开了live-restore。sudo systemctl restart docker -
Pull as usual照常拉取
Only Docker Hub goes through
registry-mirrors. For the other registries, convert the image's address first.只有 Docker Hub 会经过registry-mirrors;其他仓库的镜像,请先转换地址再拉取。docker pull nginx:1.27
containerdcontainerd
-
Point containerd at its hosts directory让 containerd 读取 hosts 目录
In
/etc/containerd/config.toml, for containerd 2.x:在/etc/containerd/config.toml中,containerd 2.x 写法:config.toml, containerd 2.x[plugins."io.containerd.cri.v1.images".registry] config_path = "/etc/containerd/certs.d"config.toml, containerd 1.x[plugins."io.containerd.grpc.v1.cri".registry] config_path = "/etc/containerd/certs.d" -
Add a hosts.toml for each registry为每个仓库写一个 hosts.toml
Run these commands. If this site is unavailable, containerd falls back to the registry itself.直接运行下面的命令。本站不可用时,containerd 会自动退回直连上游。
sudo mkdir -p /etc/containerd/certs.d/docker.io sudo tee /etc/containerd/certs.d/docker.io/hosts.toml >/dev/null <<'EOF' server = "https://registry-1.docker.io" [host."https://docker.<your-domain><你的域名>"] capabilities = ["pull", "resolve"] EOF sudo mkdir -p /etc/containerd/certs.d/gcr.io sudo tee /etc/containerd/certs.d/gcr.io/hosts.toml >/dev/null <<'EOF' server = "https://gcr.io" [host."https://gcr.<your-domain><你的域名>"] capabilities = ["pull", "resolve"] EOF sudo mkdir -p /etc/containerd/certs.d/ghcr.io sudo tee /etc/containerd/certs.d/ghcr.io/hosts.toml >/dev/null <<'EOF' server = "https://ghcr.io" [host."https://ghcr.<your-domain><你的域名>"] capabilities = ["pull", "resolve"] EOF sudo mkdir -p /etc/containerd/certs.d/registry.k8s.io sudo tee /etc/containerd/certs.d/registry.k8s.io/hosts.toml >/dev/null <<'EOF' server = "https://registry.k8s.io" [host."https://k8s.<your-domain><你的域名>"] capabilities = ["pull", "resolve"] EOF sudo mkdir -p /etc/containerd/certs.d/quay.io sudo tee /etc/containerd/certs.d/quay.io/hosts.toml >/dev/null <<'EOF' server = "https://quay.io" [host."https://quay.<your-domain><你的域名>"] capabilities = ["pull", "resolve"] EOF -
Restart containerd重启 containerd
sudo systemctl restart containerd
k3s / RKE2k3s / RKE2
-
Add the mirrors on every node在每个节点上配置镜像加速
In
/etc/rancher/k3s/registries.yaml(/etc/rancher/rke2/registries.yamlfor RKE2):编辑/etc/rancher/k3s/registries.yaml(RKE2 是/etc/rancher/rke2/registries.yaml):registries.yamlmirrors: docker.io: endpoint: - "https://docker.<your-domain><你的域名>" gcr.io: endpoint: - "https://gcr.<your-domain><你的域名>" ghcr.io: endpoint: - "https://ghcr.<your-domain><你的域名>" registry.k8s.io: endpoint: - "https://k8s.<your-domain><你的域名>" quay.io: endpoint: - "https://quay.<your-domain><你的域名>" -
Restart the service on each node在每个节点上重启服务
sudo systemctl restart k3s # server sudo systemctl restart k3s-agent # agent
Podman / CRI-OPodman / CRI-O
-
Add the mirrors配置镜像加速
Append to
/etc/containers/registries.conf, or put it in a new file in/etc/containers/registries.conf.d/:追加到/etc/containers/registries.conf,或者在/etc/containers/registries.conf.d/下新建一个文件:registries.conf[[registry]] prefix = "docker.io" location = "docker.io" [[registry.mirror]] location = "docker.<your-domain><你的域名>" [[registry]] prefix = "gcr.io" location = "gcr.io" [[registry.mirror]] location = "gcr.<your-domain><你的域名>" [[registry]] prefix = "ghcr.io" location = "ghcr.io" [[registry.mirror]] location = "ghcr.<your-domain><你的域名>" [[registry]] prefix = "registry.k8s.io" location = "registry.k8s.io" [[registry.mirror]] location = "k8s.<your-domain><你的域名>" [[registry]] prefix = "quay.io" location = "quay.io" [[registry.mirror]] location = "quay.<your-domain><你的域名>" -
Apply生效
Podman reads it right away; CRI-O needs a restart:Podman 立即生效;CRI-O 需要重启:
sudo systemctl restart crio
Kubernetes toolsKubernetes 工具
-
Pull the control plane through the mirror控制面镜像经由本站拉取
With kubeadm, on the command line or as
imageRepositoryinClusterConfiguration:kubeadm 在命令行里指定,或者写成ClusterConfiguration的imageRepository:sudo kubeadm init --image-repository k8s.<your-domain><你的域名> -
Use the containerd mirrors in kindkind 使用 containerd 的镜像加速
kind's nodes run containerd: mount the
certs.ddirectory from the containerd tab into them and point containerd at it.kind 的节点用的是 containerd:把 containerd 标签页里的certs.d目录挂进节点,并让 containerd 读取它。kind-config.yamlkind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 containerdConfigPatches: - |- [plugins."io.containerd.grpc.v1.cri".registry] config_path = "/etc/containerd/certs.d" nodes: - role: control-plane extraMounts: - hostPath: /etc/containerd/certs.d containerPath: /etc/containerd/certs.d -
Other distributions其他发行版
If the nodes run containerd or CRI-O, follow that tab.节点用的是 containerd 或 CRI-O 时,按对应的标签页配置即可。
Convert an image转换镜像地址
Paste an image from any registry this site mirrors to get the name that pulls it through the mirror.粘贴本站加速的任一仓库的镜像地址,得到经由本站拉取时的写法。
Replace the registry in an image's name with its mirror below; Docker Hub's official images need library/, as in library/nginx.把镜像地址里的仓库换成下面对应的加速地址即可;Docker Hub 的官方镜像要写成 library/ 开头,例如 library/nginx。
Mirrors加速地址
One address for each registry. Official Docker Hub images are written as library/<name>; k8s.gcr.io was frozen in 2023, so use registry.k8s.io.每个仓库一个地址。Docker Hub 的官方镜像要写成 library/<名称>;k8s.gcr.io 已于 2023 年冻结,请改用 registry.k8s.io。
-
docker.<your-domain><你的域名>Docker Hub (docker.io) This site当前
-
gcr.<your-domain><你的域名>gcr.io This site当前
-
ghcr.<your-domain><你的域名>ghcr.io This site当前
-
k8s.<your-domain><你的域名>registry.k8s.io This site当前
-
quay.<your-domain><你的域名>quay.io This site当前
Status服务状态
A separate status page watches these mirrors from outside: whether each one answers, and how it has done lately.这些加速地址由独立的状态页从外部监测:现在能否访问,以及最近的情况。
Status page状态页
Questions常见问题
A pull fails with 404, manifest unknown, or 503拉取时报 404、manifest unknown 或 503
Usually the name is wrong. Official Docker Hub images are library/<name>, as in library/nginx; for other images, check that the name and tag exist in the registry. Convert an image checks the name for you.多半是镜像名写错了:Docker Hub 的官方镜像要写成 library/<名称>,例如 library/nginx;其他镜像请确认仓库里确实有这个名称和标签。转换镜像地址会帮你检查名称。
429 Too Many Requests报 429 Too Many Requests
The registry, Docker Hub in particular, limits this site's address. Cached images are not affected; for others, try again later.仓库(尤其是 Docker Hub)按本站的出口地址限流。已缓存的镜像不受影响,没缓存过的请稍后重试。The registry, Docker Hub in particular, limits this site's address, and every user shares that limit. Try again later.仓库(尤其是 Docker Hub)按本站的出口地址限流,所有用户共用这个额度,请稍后重试。
5xx, timeouts, or downloads that break off报 5xx、超时或下载中断
Usually a passing problem with the registry or the network; try again. See also the status page.一般是仓库或网络的临时波动,重试即可。也可以看看状态页。
Are images cached?镜像会缓存吗?
Yes. The first pull fetches the image from the registry and caches it; later pulls are served from here. Images nobody has pulled for 7 days are removed, and a tag is checked with the registry again after 5 minutes at most.会。首次拉取时从仓库取回并缓存,之后直接从本站返回;7 天内没人拉过的镜像会自动清理。同一个标签最多 5 分钟就会再向仓库确认一次是否更新。No. Nothing is stored here: every pull is fetched from the registry and passed through.不会。本站不保存镜像,每次拉取都从仓库取回,再转发给你。
I get an old version after a tag was updated标签更新后拉到的是旧版本?
Tags that change, such as latest, can lag the registry by up to 5 minutes. Pull by digest (@sha256:…) when you need an exact version.latest 这类会变的标签,仓库更新后最多 5 分钟才能拉到新版本。需要确定版本时,请按 digest(@sha256:…)拉取。Every pull goes to the registry, so you get its current version. Pull by digest (@sha256:…) when you need an exact one.本站每次都回源,拉到的就是仓库当前的版本。需要确定版本时,请按 digest(@sha256:…)拉取。
Can I push or search?能推送镜像或搜索吗?
No. This site only pulls: docker push, docker search and listing repositories are not supported.不能。本站只放行拉取:docker push、docker search 和列出仓库都不支持。
What is logged?会记录什么?
Access logs (client address, image, time, status), used only to run the service and to stop abuse. See the privacy notice.会记录访问日志(来源地址、镜像、时间、状态),只用于运维和防止滥用。详见隐私说明。