如果在拉取 Docker 镜像时遇到问题

例如:

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

由于国内网络限制,需编辑 /etc/docker/daemon.json 文件并添加以下内容(如果不存在就创建):

编辑

sudo vi /etc/docker/daemon.json 

添加如下JSON配置(如果原本有其他配置,追加json字段registry-mirrors即可)

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://noohub.ru",
    "https://huecker.io",
    "https://dockerhub.timeweb.cloud",
    "https://docker.rainbond.cc",
    "https://dockerhub.icu",
    "https://docker.chenby.cn",
    "https://docker.1panel.live",
    "https://docker.awsl9527.cn",
    "https://docker.anyhub.us.kg",
    "https://dhub.kubesre.xyz",
    "https://docker.1ms.run",
    "https://docker.xuanyuan.me"
  ]
}

完成编辑后,重新加载 daemon.json 文件并重启 Docker:

sudo systemctl daemon-reload
sudo systemctl restart docker