问题概述

如下图:

 

具体内容如下:

[root@localhost tomcat]# docker build -f /opt/docker/tomcat/dockerfilebytomcat -t huazai/web/runtime/tomcat:v1.0 .
Sending build context to Docker daemon  199.7MB
Step 1/16 : FROM centos
 ---> 75835a67d134
Step 2/16 : MAINTAINER alibaba_huazai<who.seek.me@java98k.vip>
 ---> Running in 0964c1d94546
Removing intermediate container 0964c1d94546
 ---> fc3103b53aeb
Step 3/16 : COPY b2c_data.db /opt/data/b2c_data.db
 ---> 1fa3b98fbb82
Step 4/16 : ADD jdk-8u151-linux-x64.tar.gz /usr/local/
 ---> f22664a4a5c1
Step 5/16 : ADD apache-tomcat-9.0.12.tar.gz /usr/local/
 ---> 7f30d9675eda
Step 6/16 : RUN yum -y install net-tools
 ---> Running in f4f8321831a8
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors


 One of the configured repositories failed (Unknown),
 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=<repoid> ...

     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 <repoid>
        or
            subscription-manager repos --disable=<repoid>

     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=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
The command '/bin/sh -c yum -y install net-tools' returned a non-zero code: 1

 

 

解决办法

yum 帮助提示的解决方案如下:

存储库配置失败的(未知)之一,而且yum没有足够的缓存数据来继续(在这一点上唯一的)。导致安全的 yum 可能会出现使用失败的情况,有以下列出了一些方法可以解决这个问题:

1、联系以上存储库源,让他们修复该问题。

 

2、重新配置 baseurl /etc 。对于存储库,要指向一个 working upstream。如果您使用的是一个更新的存储库,这通常非常有用的。

 

3、在临时禁用存储库的情况下运行该命令

 yum --disablerepo=<repoid> ...

 

4、永久禁用存储库,因此 yum 在默认情况下不会使用它。然后 yum 将忽略存储库,直到永久启用它再次或者使用 —— enablerepo用于临时使用:

    yum-config-manager --disable <repoid>
或者
    subscription-manager repos --disable=<repoid>

 

5、配置要跳过的失败存储库(如果该存储库不可用)。请注意,当它运行大多数命令时,yum 将尝试回购。所以每次都会尝试失败(因此 yum 将会是非常的慢)。如果这是一个非常暂时的问题,则可以通过以下方法解决:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

 

这儿博主使用的方式:

# 清除缓存
rm /var/lib/rpm/__db*

在错误信息中已经看到了, yum 中没有足够的缓存空间,这儿只需要清理以下就可以了。

 

 

 


好了,关于 Docker下CentOS镜像中yum命令无效的解决办法  就写到这儿了,如果还有什么疑问或遇到什么问题欢迎扫码提问,也可以给我留言哦,我会一一详细的解答的。 
歇后语:“ 共同学习,共同进步 ”,也希望大家多多关注CSND的IT社区。


作       者:华    仔
联系作者:who.seek.me@java98k.vip
来       源:CSDN (Chinese Software Developer Network)
原       文:https://blog.csdn.net/Hello_World_QWP/article/details/84631197
版权声明:本文为博主原创文章,请在转载时务必注明博文出处!
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐