docker鏡像倉庫hub.docker.com無法訪問1 介紹dockerhub為什么無法訪問2 解決辦法2.1 使用魔法2.2 使用國內(nèi)鏡像加速2.2.1 docker配置:2.2.2 containerd配置:2.3 使用博主個人鏡像倉庫2.3.1 目前有如下鏡像倉庫,后續(xù)會陸續(xù)增加2.3.2 使用方式2.3.3 拉取鏡像3 總結(jié)
docker鏡像倉庫hub.docker.com無法訪問
文章主要內(nèi)容:
1 介紹dockerhub為什么無法訪問
最近許多群友都詢問為什么無法訪問Docker鏡像倉庫,于是我也嘗試去訪問,結(jié)果果然無法訪問。

大家的第一反應(yīng)就是給墻了,通過ping檢測紅的很可怕。

實際上是DNS被污染了,導(dǎo)致很多用戶都無法訪問。至于什么是DNS污染,大家可以自行查詢,這里主要講解怎么解決dockerhub無法訪問的問題。

2 解決辦法
由于無法訪問,導(dǎo)致我們運維人員和開發(fā)者使用docker鏡像變得極其不方便,然而我們可以使用下面幾種方法來解決這個問題。
2.1 使用魔法
(這里就不展開說了,大家懂的都懂)
2.2 使用國內(nèi)鏡像加速
常見的國內(nèi)加速服務(wù):
科大鏡像:https://docker.mirrors.ustc.edu.cn
網(wǎng)易:http://hub-mirror.c.163.com
阿里云:https://<你的ID>.mirror.aliyuncs.com
廢話不多說,直接上命令
2.2.1 docker配置:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["鏡像加速地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
# 示例
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://eph8xfli.mirror.aliyuncs.com"]# 這是博主自己的阿里云鏡像加速地址,大家可以更換為自己的
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
阿里云官網(wǎng)也有不同操作系統(tǒng)的操作文檔,大家可以自行查閱
https://help.aliyun.com/document_detail/60750.html?spm=a2c4g.348824.0.0.742fa42dEeTNYo

2.2.2 containerd配置:
包括K8S鏡像加速
vim /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://docker.mirrors.ustc.edu.cn","http://hub-mirror.c.163.com"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
endpoint = ["https://gcr.mirrors.ustc.edu.cn"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://gcr.mirrors.ustc.edu.cn/google-containers/"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."quay.io"]
endpoint = ["https://quay.mirrors.ustc.edu.cn"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
endpoint = ["https://ghcr.dockerproxy.com"]
2.3 使用博主個人鏡像倉庫
本鏡像倉庫在阿里云,主要包含K8S相關(guān)鏡像。如果大家有所需求,可以聯(lián)系博主增加相關(guān)鏡像。
鏡像每天持續(xù)同步更新,目前有80+倉庫,包含新版和常用鏡像版本。
2.3.1 目前有如下鏡像倉庫,后續(xù)會陸續(xù)增加
docker.elastic.co:
- elasticsearch/elasticsearch
- kibana/kibana
- logstash/logstash
- beats/filebeat
- beats/heartbeat
- beats/packetbeat
- beats/auditbeat
- beats/journalbeat
- beats/metricbeat
- apm/apm-server
- app-search/app-search
quay.io:
- coreos/flannel
- ceph/ceph
- cephcsi/cephcsi
- csiaddons/k8s-sidecar
- csiaddons/volumereplication-operator
- prometheus/prometheus
- prometheus/alertmanager
- prometheus/pushgateway
- prometheus/blackbox-exporter
- prometheus/node-exporter
- prometheus-operator/prometheus-config-reloader
- prometheus-operator/prometheus-operator
- brancz/kube-rbac-proxy
- cilium/cilium
- cilium/operator-generic
- thanos/thanos
- cilium/certgen
- cilium/hubble-relay
- cilium/hubble-ui-backend
- cilium/hubble-ui
- cilium/cilium-etcd-operator
- cilium/operator
- cilium/startup-script
- cilium/clustermesh-apiserver
- coreos/etcd
- metallb/speaker
- frrouting/frr
- goharbor/nginx-photon
- goharbor/harbor-portal
- goharbor/harbor-core
- goharbor/harbor-jobservice
- goharbor/registry-photon
- goharbor/harbor-registryctl
- goharbor/chartmuseum-photon
- goharbor/trivy-adapter-photon
- goharbor/notary-server-photon
- goharbor/notary-signer-photon
- goharbor/harbor-db
- goharbor/redis-photon
- goharbor/harbor-exporter
k8s.gcr.io:
- dns/k8s-dns-node-cache
- metrics-server/metrics-server
- kube-state-metrics/kube-state-metrics
- prometheus-adapter/prometheus-adapter
- sig-storage/nfs-subdir-external-provisioner
- sig-storage/csi-node-driver-registrar
- sig-storage/csi-provisioner
- sig-storage/csi-resizer
- sig-storage/csi-snapshotter
- sig-storage/csi-attacher
- sig-storage/nfsplugin
registry.k8s.io:
- pause
- etcd
- conformance
- kube-proxy
- kube-apiserver
- kube-scheduler
- kube-controller-manager
- coredns/coredns
- ingress-nginx/controller
- ingress-nginx/opentelemetry
- ingress-nginx/controller-chroot
- ingress-nginx/kube-webhook-certgen
- defaultbackend-amd64
- cpa/cluster-proportional-autoscaler
- autoscaling/addon-resizer
gcr.io:
- kaniko-project/executor
- google-samples/xtrabackup
- kubebuilder/kube-rbac-proxy
docker.io:
- calico/node
- calico/typha
- calico/cni
- calico/node
- calico/kube-controllers
- calico/pod2daemon-flexvol
- kubesphere/openelb
- aledbf/kube-keepalived-vip
2.3.2 使用方式
docker.elastic.co/kibana/{image_name} ==> registry.cn-hangzhou.aliyuncs.com/waluna/{image_name}
quay.io/csiaddons/{image_name} ==> registry.cn-hangzhou.aliyuncs.com/waluna/{image_name}
k8s.gcr.io/{image_name} ==> registry.cn-hangzhou.aliyuncs.com/waluna/{image_name}
....
2.3.3 拉取鏡像
docker pull registry.cn-hangzhou.aliyuncs.com/waluna/kube-scheduler:[鏡像版本號]
crictl pull registry.cn-hangzhou.aliyuncs.com/waluna/kube-scheduler:[鏡像版本號]
3 總結(jié)
個人感覺使用魔法最方便,但是很多同學(xué)都不會使用魔法。所以大家可以根據(jù)自己喜歡的方式去選擇使用國內(nèi)鏡像加速(本文2.2)還是博主鏡像倉庫(本文2.3)。
閱讀原文:原文鏈接
該文章在 2025/9/11 9:58:57 編輯過