赞
踩
在pull镜像时遇到如下报错:
┌──(root㉿kali)-[/home/longl]
└─# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
c1ec31eb5944: Retrying in 1 second
error pulling image configuration: download failed after attempts=6: dial tcp 173.252.88.67:443: connect: connection refused
解决方法:换源!!!!!!!!!
首先,你需要找到一个可用的镜像源。一些常见的国内镜像源包括:
https://registry.cn-hangzhou.aliyuncs.com
https://mirrors.tencent.com/docker
https://mirror.ccs.tencent.com/dockerhub
https://docker.mirrors.ustc.edu.cn/
https://dockerhub.douban.com/
注意阿里云提供:
[系统分配前缀].mirror.aliyuncs.com
具体上阿里云容器HUB控制台查看(需要账号)
阿里云容器HUB控制台:
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
Docker 可以通过修改配置文件来更换镜像源。你可以使用 Docker 提供的 daemon.json
文件来配置镜像源。
打开或创建 daemon.json
文件。这个文件通常位于 /etc/docker/
目录下:
如果没有创建daemon.json文件就自己创建一下
sudo touch /etc/docker/daemon.json
编辑daemon.json
sudo vim /etc/docker/daemon.json
在 daemon.json
文件中添加以下内容,将 MIRRORS
替换为你选择的镜像源:
{
"registry-mirrors": ["https://MIRRORS.mirror.com"]
}
例如,如果你想使用中科大的镜像源,你应该这样写:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
建议使用阿里的镜像加速器提供的源
保存并关闭文件。
配置完成后,需要重启 Docker 服务以使配置生效:
sudo systemctl restart docker
如果修改成功,可以在info中查看到修改后的源:
sudo docker info
为了验证是否成功更换了镜像源,你可以尝试拉取一个镜像,比如 hello-world
:
docker pull hello-world
如果镜像成功下载,并且过程中没有出现之前的错误,那么更换镜像源就成功了。
成功!!!!
┌──(root㉿kali)-[/etc/docker]
└─# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
┌──(root㉿kali)-[/etc/docker]
└─# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
.env
文件或 Docker Compose 的配置文件来指定镜像源。更换镜像源是一个常见的操作,特别是在网络条件不佳或者需要访问特定地区镜像源的情况下。通过上述步骤,你应该能够顺利地更换 Docker 的镜像源。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。