解决centOS安装docker问题,fastestmirror, langpacksLoading mirror speeds from cached hostfilehttp...

       本人在centOs7中安装docker中遇到的两个问题,费了九牛二虎之力终于解决了!!!如下问题以及解决方案。

(1)问题1:fastestmirror, langpacksLoading mirror speeds from cached hostfile

http://mirrors.aliyun.com/docker-/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found.

注意!!!所有不是root用户在执行代码前加sudo,不然显示权限不足,执行失败。

如图1:(第一步安装工具就出现了问题)

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

(2)解决方案:

1)查看有没有docker的安装包

 yum list installed | grep docker

2)查看 yum 软件源配置文件(.repo 文件),因为在我没有解决这个问题之前尝试各种方法,中途下载了,有的友友可能没有,没有就是没有返回的。

cd /etc/yum.repos.d
ls

3)再把它删除,用ls查不到了。

rm -rf *

4)查看缓存,显示0

yum repolist all

5)下载阿里镜像源,看哪个不报错用哪个,我用第一个成功了

curl -o /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

6)生成yum缓存,发现有数据返回,成功的

yum makecache

7)安装工具成功了!!!

yum install -y yum-utils device-mapper-persistent-data lvm2

(3)问题2:Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp 173.236.212.42:443: i/o timeout.
See 'docker run --help'.

运行hello-world报错

docker run hello-world

(4)解决方案

1)修改 /etc/docker/daemon.json文件,这个文件是配置项目参数,默认不存在的,需要创建,用vi 编辑进去就自动创建了,里面就是空白的。

vi /etc/docker/daemon.json

看了很多的blog是把阿里的镜像加速器编辑(圈红的那部分代码,这是要自己注册一个阿里云账号,然后再去查看)进去的,但是我的还是解决不了问题。

2)这是我发现的另一个blog把下面内容编辑进去,然后我的就work it out了!!!


{
"registry-mirrors":[
"https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io", 
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc"
  
  ] 
}  

3)重启docker并查看其状态。

systemctl restart docker
 systemctl status docker

4)再次运行hello-world,终于把它从仓库pull下来了!

docker run hello-world

5)查看下载的镜像,hello-world已在本地。

docker images

到此两个问题已经解决了。

参考博客:1,blog.youkuaiyun.com/centOs换源      2,blog.youkuaiyun.com/yum依赖导致问题

3,blog.youkuaiyun.com/解决docker镜像问题

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值