【完全解决】Docker安装完成运行hello-world镜像失败:Unable to find image ‘hello-world:latest‘ locallylatest:

--------------------------------------------(建议直接看解决方案部分) --------------------------------------------

问题描述

按照官网安装完Docker,在最后一步检验docker是否安装成功,即运行sudo docker run hello-world这条命令时一直一直一直出现以下问题:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Retrying in 1 second 
docker: error pulling image configuration: download failed after attempts=6: dial tcp 162.125.82.7:443: connect: connection refused.
See 'docker run --help'.

如下图:

然后尝试了很多种方法,例如:

方法一如何完美解决 “error pulling image configuration: download failed after attempts=6: dial tcp 59.188.250.54-腾讯云开发者社区-腾讯云 (tencent.com)

方法二: 使用docker拉取镜像一直网路拒绝连接 - 守漠待花开 - 博客园 (cnblogs.com)

方法三: Bug记录:Ubuntu Docker pull 报错 error pulling image configuration: download failed after attempts=6 - 知乎 (zhihu.com)

其中对于方法一中添加的镜像加速地址,网上有很多版本,比如只配置了阿里加速、只配置了中科大加速、只配置了网易加速.......

看了很多对于这个问题的解决方案,都跟方案一很相似,觉得这个并不是问题的解(因为先入为主,先看了方案一,再看的其它版本的)就没有再去试其它同类型的答案的方法!

并且!因为我看方法一中包含的比较多源,认为这都不行,就觉得这个不是产生问题的原因,如图:

然后,我开始找其它的方法,例如,方法三,此时就是方法一 + 方法三都不行! 


又经过了2天的折腾以后,重新回到方法一类似的解法上来,再很认真看了其它的方法(http://t.csdnimg.cn/T5gt0)后,发现自己所用的方法一中并没有阿里镜像加速器!

于是想着试试,把阿里镜像加速器加入到配置文件中,没想到加入阿里镜像服务器后就运行成功了!!!

最终配置文件如下:

{"registry-mirrors": [
    "https://s*****fq.mirror.aliyuncs.com",
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com"
  ]
}

解决方案

1、首先检查是否存在daemon.json文件,如果没有,就需要创建:

sudo vim /etc/docker/daemon.json
//下面为创建方法,如果直接已经有了daemon.json文件,请忽略!
sudo mkdir -p /etc/docker    //创建目录

2、然后在文件中插入如下内容:

{"registry-mirrors": [
    "https://s*****fq.mirror.aliyuncs.com",
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com"
  ]
}

注意阿里镜像加速器必须加上!!!

方法见:http://t.csdnimg.cn/T5gt0

阿里镜像加速器的地址为:容器镜像服务 (aliyun.com)

其它镜像加速器可照抄 

3、重启Docker服务

sudo systemctl daemon-reload
sudo systemctl restart docker

4、重新运行hello-world 

参考文献

http://t.csdnimg.cn/v3M1Y

http://t.csdnimg.cn/T5gt0

使用docker拉取镜像一直网路拒绝连接 - 守漠待花开 - 博客园 (cnblogs.com)

Bug记录:Ubuntu Docker pull 报错 error pulling image configuration: download failed after attempts=6 - 知乎 (zhihu.com)

国内无法拉取Docker镜像了?这些方法拯救你的Docker-腾讯云开发者社区-腾讯云 (tencent.com)

评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值