发布时间:2022-08-17 13:29
在安装Docker-CE的时候遇到报错:
第一个错误:
原因:yum源只下载了docker-ce.repo,没有CentOS-Base.repo
解决:根据这个报错可以看出是container-selinux没安装的原因,所以我们只需要安装一下contain-SElinux包就可以了
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
第二个错误:
第一个错误解决后,下载了CentOS-Base.repo源,但是yum clean all;yum repolist
时报错
报错:http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
解决法1:HTTP请求失败,尝试本地访问之前wget下来的 CentOS-Base.repo 发现其中的:
1:http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
2:http://mirrors.aliyun.com/centos/7/os/$basearch/
curl 访问前面网址1访问到的阿里云内容不正确;访问网址2得到内容是正确的;所以将变量$releasever全改为7(7是由于linux系统版本为7.6,使用命令cat /etc/redhat-release查看系统版本),正确访问。
改完之后,执行yum clean all 以及 yum repolist
成功。
解决法2:CentOS-Base.repo源里改为下面内容(精简了方法1CentOS-Base.repo中的内容,只保留了下载docker-ce需要的镜像源,和法1操作一样,改$releasever为版本号7)。
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
错误1参考:https://blog.csdn.net/f2001523/article/details/114488938
错误2参考:https://www.cnblogs.com/xuelisheng/p/11452926.html
yum list docker-ce.x86_64 --showduplicates | sort -r
#查看docker所有版本
yum -y install docker-ce-20.10.12-3.el7
#安装指定版本docker