当前位置: 代码网 > 服务器>服务器>云虚拟主机 > docker pull出现错误或速度慢具体解决办法

docker pull出现错误或速度慢具体解决办法

2024年06月13日 云虚拟主机 我要评论
常见问题现象在使用 docker 拉取镜像时出现错误:error response from daemon: get “https://registry-1.docker.io/v2/&r

常见问题现象

  • 在使用 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)

  • 在使用 docker 时遇到拉取镜像速度慢的问题

出现以上问题可以使用国内的镜像源可以提高下载速度。

使用阿里镜像加速器

docker 配置文件位于 /etc/docker/daemon.json。如果文件不存在,可以手动创建它。将以下内容添加到配置文件中:

整体复制执行命令:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'eof'
{
  "registry-mirrors": ["https://[系统分配前缀].mirror.aliyuncs.com"]
}
eof
sudo systemctl daemon-reload
sudo systemctl restart docker

根据以下方法获取其中的 [系统分配前缀]

获取阿里云系统分配前缀

阿里云官方文档:

https://help.aliyun.com/zh/acr/user-guide/accelerate-the-pulls-of-docker-official-images

登录阿里云查询拥有的镜像加速器地址:
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

在这里插入图片描述

其他docker镜像源

镜像源地址
docker中国区官方https://registry.docker-cn.com
网易http://hub-mirror.c.163.com
中科大http://mirrors.ustc.edu.cn/
清华大学https://mirrors.tuna.tsinghua.edu.cn/
搜狐http://mirrors.sohu.com/

附:从仓库中拉取具有多个镜像的仓库(-a, --all-tags)

默认情况下,docker pull从注册表中拉取单个镜像。一个仓库可以包含多个镜像。要从仓库中拉取所有镜像,请在使用docker pull时提供-a(或--all-tags)选项。

以下命令从ubuntu仓库中拉取所有镜像:

docker image pull --all-tags ubuntu

拉取完成后,使用docker image ls命令(或docker images的简写)来查看已拉取的镜像。以下示例显示了本地存在的所有ubuntu镜像:

docker image ls --filter reference=ubuntu
repository   tag       image id       created        size
ubuntu       18.04     c6ad7e71ba7d   5 weeks ago    63.2mb
ubuntu       bionic    c6ad7e71ba7d   5 weeks ago    63.2mb
ubuntu       22.04     5ccefbfc0416   2 months ago   78mb
ubuntu       focal     ff0fea8310f3   2 months ago   72.8mb
ubuntu       latest    ff0fea8310f3   2 months ago   72.8mb
ubuntu       jammy     41ba606c8ab9   3 months ago   79mb
ubuntu       20.04     ba6acccedd29   7 months ago   72.8mb

总结 

到此这篇关于docker pull出现错误或速度慢具体解决办法的文章就介绍到这了,更多相关docker pull出错或速度慢内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com