目录:
写在前面:心得+本文精华(本文该问题的思考解决方式)
写在后面:为解决本文该问题----我的折腾
♡ 心得:修改文件,记得备份!尤其是配置文件
♡ 本文该问题的思考解决方式:实际上就是开发中遇到的版本问题
linux版本centos7.6(1080)
Dockerfile 文件内容如下:
FROM centos
MAINTAINER ylb<11>
ADD jdk-8u301-linux-aarch64.tar.gz /usr/local/
ADD apache-tomcat-9.0.62.tar.gz /usr/local/
RUN yum -y install vim
ENV MYPATH /usr/local/
WORKDIR $MYPATH
ENV JAVA_HOME /usr/local/jdk1.8.0_301
ENV CLASSPATH $JAVA_HOME/lib/
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.62
ENV CATALINA_BASH /usr/local/apache-tomcat-9.0.62
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$CATALINA_HOME/lib
EXPOSE 8080
CMD /usr/local/apache-tomcat-9.0.62/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.62/logs/catalina.out
RUN yum -y install vim
就报错,Cannot prepare internal mirrorlist: No URLs in mirrorlist究其根因是版本问题
大白话就是,狂神当时(last)最新的centos版本是7.xx,而现在(last)最新的版本的centos是8.xxx
伴随着不同centos版本所兼容的yum,它的内容是不同的
举例:Centos-vault-6.10.repo 和 Centos-vault-8.5.2111.repo的对比:发现版本6的内容比较少,它相对于8的话,没有[centosplus]、[PowerTools]、[AppStream]
##### 最最重要的是:本次问题报错所没有AppStream,而这个AppStream是版本8的centos才有的,是版本8的新增内容,在版本7是没有它的,官网没有提供!
认识到版本的重要性了吧,内容的增删改!
涉及到centos版本的地方,指明版本
,如本文问题核心Dockerfile中的 FROM centos:7在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org
http://mirrors.ustc.edu.cn/help/centos.html
https://mirrors.aliyun.com/repo/
https://mirrors.cloud.tencent.com/repo/
补充:看文章的时候,注意文章涉及到链接的地方,版本、版本、版本!
1)有时候文章提供了解决方法,但是版本和咱对不上,怎么办?
- 去掉一些参数,自己进入网站挑选合适自己的版本的
https://mirrors.aliyun.com/repo/
- #### 结果是无效折腾
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org
CentOS Linux 8 - AppStream 21 B/s | 38 B 00:01
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
The command '/bin/sh -c yum -y install vim' returned a non-zero code: 1
① 如果你仍然需要运行你的旧CentOS 8,你可以在/etc/yum.repos中更新repos.d使用vault.centos.org代替mirror.centos.org。
cd /etc/yum.repos.d
vi CentOS-AppStream.repo
[appstream]
name=CentOS $releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
baseurl=https://vault.centos.org/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
② 执行命令:
yum clean all
yum makecache
https://vault.centos.org/centos/7/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Determining fastest mirrors
https://vault.centos.org/centos/7/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
One of the configured repositories failed (CentOS Linux 7 - AppStream),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=appstream ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable appstream
or
subscription-manager repos --disable=appstream
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=appstream.skip_if_unavailable=true
failure: repodata/repomd.xml from appstream: [Errno 256] No more mirrors to try.
https://vault.centos.org/centos/7/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
是因为yum已经更新了的原因导致的 http://mirrors.163.com/centos/ 进官网可以看到已经更新到7.x了
打开CentOS7-Base.repo(名字可能不一样),一般在 ./etc/yum.repos.d文件夹下
vim /etc/yum.repos.d/CentOS7-Base.repo
解决阿里云CentOS7 yum安装appstream报错,更新yum后无法makecache的问题
将/etc/yum.repos.d/CentOS-AppStream.repo,替换为如下:
[appstream]
name=CentOS-$releasever
baseurl=http://mirrors.aliyun.com/centos/$releasever/appstream/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
1)将源文件备份
cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/
2)下载阿里源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3)更新源里面的地址
sed -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*
sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*
4)生成缓存
yum clean all && yum makecache
问题是:执行第四步yum clean all && yum makecache
报错:failure: repodata/repomd.xml from AppStream: [Errno 256] No more mirrors to try.
One of the configured repositories failed (CentOS-7-stream - AppStream - mirrors.aliyun.com),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=AppStream ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage: yum-config-manager --disable AppStream
or
subscription-manager repos --disable=AppStream
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise: yum-config-manager --save --setopt=AppStream.skip_if_unavailable=true</code></pre>
failure: repodata/repomd.xml from AppStream: [Errno 256] No more mirrors to try.
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')
https://mirrors.aliyun.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
http://mirrors.aliyun.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7-stream/AppStream/x86_64/os/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
[root@iZwz9535z41cmgcpkm7i81Z yum.repos.d]#
1)查看centos系统本身所安装的yum依赖包
rpm -qa|grep yum
2)卸载这些软件包 rpm -e xx --nodeps
查看系统的命令:
cat /etc/redhat-release
查看系统的位数:
file /bin/ls
找到对应版本的os/x86_64/Packages/
分别下载[注意:我的linux版本是centos7.6(1080)]:
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/yum-3.4.3-1①61.el7.centos.noarch.rpm
5)安装yum依赖包
rpm -ivh yum-*
6)更换CentOS-Base.repo
① 进入 /etc/yum.repos.d,先备份
cd /etc/
cd yum.repos.d
# 备份一下:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
② 进入官网:http://mirrors.ustc.edu.cn/help/centos.html
自己先建立一个txt文件,内容拷贝进去后,修改名称为CentOS-Base.repo
使用工具xftp,将CentOS-Base.repo 传输到/etc/yum.repos.d目录
#
#
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
③ 执行命令:
yum clean all
yum makecache
还报错,你以为到这里,我就放弃了吗?
---yes, 我的贪吃蛇已经快排名第一了哈哈哈
- 继续解决~~~
哇塞,玩完贪吃蛇的我,不一样了,眼睛不一样了,一瞅,立马发现了,自己的centos的配置文件下的yum.repos.d/目录下的文件和别人不同
- 发现缺少文件了
"将/etc/yum.repos.d/目录下的CentOS-Base.repo、CentOS-AppStream.repo、CentOS-Extras.repo中的mirrorlist注释掉,将baseurl 修改为阿里源……"
结果悲捶了,只剩下一个Centos-Base.repo文件了-----说明了备份的重要性
】:将/etc/yum.repos.d 清空后,重新下载
# 删除yum.repos.d目录下所有文件
rm -f /etc/yum.repos.d/*
# 然后重新下载阿里的源(确保网络连接)--注意版本哦,我的centos是7的版本
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 清理缓存
yum clean all
● 所以,咱没备份,配置文件全没了,咱重置一下系统吧
帮助文档:https://docs.docker.com/get-started/overview/
sudo yum remove docker <br />
docker-client <br />
docker-client-latest <br />
docker-common <br />
docker-latest <br />
docker-latest-logrotate <br />
docker-logrotate <br />
docker-engine
# 2、使用仓库安装
# 需要的安装包
sudo yum install -y yum-utils
# 设置仓库【默认是国外的,我们不要使用国外的,需要使用国内的阿里云镜像地址】
sudo yum-config-manager <br />
--add-repo <br />
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io
# 4、启动 Docker
systemctl start docker
# 检查是否成功启动
docker version
# 5、测试hello-world
docker run hello-world
# 查看下载的镜像
docker images
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://o10wzpax.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
● 发现/etc/yum.repos.d/目录下:
折腾累了,贪吃蛇也玩得手指起泡了,突然这次又火眼金睛,发现了阿里、腾讯镜像中,好奇对比一下centos7—Base.repo 和 centos8—Base.repo,
还有,之前搜索发现:CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org
顺便对比一下:Centos-vault-6.10.repo 和 Centos-vault-8.5.2111.repo (因为没有版本7的,所以找6的来对比)
恍惚之间,想到了时间是一把杀猪刀,现在是2022年了,而我的学习视频,狂神的Docker最新超详细版教程通俗易懂视频,是2020年的
- ### 在下版本,有何贵干!
手机扫一扫
移动阅读更方便
你可能感兴趣的文章