Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist: No URLs

在阿里云服务器上 docker build 出现错误
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist

[root@iZbp18knnewwywd8jkfZ dockerfile]# docker build -f mydockerfile-centos -t mycentos:0.1 .
Sending build context to Docker daemon  2.048kB
Step 1/10 : FROM centos
latest: Pulling from library/centos
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
 ---> 5d0da3dc9764
Step 2/10 : MAINTAINER suifeng<test@qq.com>
 ---> Using cache
 ---> e49f6464cec5
Step 3/10 : ENV MYPATH /usr/local
 ---> Using cache
 ---> 758e1e76b032
Step 4/10 : WORKDIR $MYPATH
 ---> Using cache
 ---> 25870bf309c1
Step 5/10 : RUN yum -y install vim
 ---> Running in 16e7a2d64399
CentOS Linux 8 - AppStream                       33  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
[root@iZbp18knnewwywd8jkfZ dockerfile]# 

尝试过很多解决办法,包括换镜像源,防火墙等等
都没有得到解决
百度了一通说因为centOS8于2021年12月31日停止了源的服务,而现在时间是2022年3月了,所以之前的方法都不行的原因所在(本质是源的问题)。
未具体指明 centos7 的镜像时,它会默认去找最新的镜像,然后就一直失败
然后我将脚本中FROM centos改成指定版本FROM centos:FROM centos7
然后就成功了。。

[root@iZbp18knnewwywd8jkfZ dockerfile]# cat mydockerfile-centos 
FROM centos:centos7
MAINTAINER suifeng<test@qq.com>

ENV MYPATH /usr/local
WORKDIR $MYPATH

RUN yum -y install vim
RUN yum -y install net-tools

EXPOSE 80

CMD echo $MYPATH
CMD echo "----end----"
CMD /bin/bash

参考文章:https://blog.csdn.net/qq_45662411/article/details/122817998
https://help.aliyun.com/document_detail/405635.html?spm=5176.smartservice_service_chat.0.0.712c3f1bBoZ19I

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值