说明
在使用 Docker 拉取镜像的时候,有时候需要很长的时候,甚至拉取失败的情况。
解决方案
修改 /etc/docker/daemon.json 文件中 registry-mirrors 属性。
注意:该文件内容是 JSON 格式。
如果不存在 /etc/docker/daemon.json 文件,可以手动创建一个。
# mkdir -p /etc/docker
# touch daemon.json
在文件中添加下面的内容
{
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}
如果文件已经存在,并且文件中已经存在内容。例如:其他内容是:"otherKey":"otherValue"(随便写的)。
将 registry-mirrors 的键和值写在后面。
{
"otherKey":"otherValue",
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}
重启 docker
# systemctl daemon-reload
# systemctl restart docker
再次尝试拉取镜像,速度会快很多。