文章目录
问题
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
尝试过很多解决方案(包括:换镜像源,防火墙,selinux等),也换过很多系统(包括:阿里云服务器,centos7,centos8)都没有解决这个问题,最后指定了 centos镜像为 centos7 后成功了,阿里云服务器,centos7,centos8这三种环境均是以此为解决方案。
#猜测是最新的centos镜像存在问题,所以我更换为了centos7的镜像
解决方案(阿里云、centos7、centos8均是以此解决的)
- 查看本地镜像
未具体指明 centos7 的镜像时,它会默认去找最新的镜像:失败(具体的shell脚本)
docker pull centos:centos7
cat >>df2<<EOF
FROM centos
RUN yum install -y wget net-tools
CMD echo "Hello Wolrd"
EOF
docker build -f df2 -t image_name .
# . 是输出路径
# 上下文路径,是指 docker 在构建镜像,有时候想要使用到本机的文件(比如复制),docker build 命令得知这个路径后,会将路径下的所有内容打包。
具体指明使用centos7的镜像:成功(具体的shell脚本)
#如果要具体执行的话,请将上面那串代码也一并复制粘贴
sed "s/cen.*/centos:centos7/" df2 > df3
docker build -f df3 -t image_name .
docker images | grep image.*
Successfully built 348a7ee19977 Successfully tagged image_name:latest
#虽成功构建了镜像,但心累