docker build yum install Could not retrieve **
> [2/2] RUN yum install -y wget:
#0 0.308 Loaded plugins: fastestmirror, ovl
#0 0.367 Determining fastest mirrors
#0 0.373
#0 0.373
#0 0.373 One of the configured repositories failed (Unknown),
#0 0.373 and yum doesn't have enough cached data to continue. At this point the only
#0 0.373 safe thing yum can do is fail. There are a few ways to work "fix" this:
#0 0.373
#0 0.373 1. Contact the upstream for the repository and get them to fix the problem.
#0 0.373
#0 0.373 2. Reconfigure the baseurl/etc. for the repository, to point to a working
#0 0.373 upstream. This is most often useful if you are using a newer
#0 0.373 distribution release than is supported by the repository (and the
#0 0.373 packages for the previous distribution release still work).
#0 0.373
#0 0.373 3. Run the command with the repository temporarily disabled
#0 0.373 yum --disablerepo=<repoid> ...
#0 0.373
#0 0.373 4. Disable the repository permanently, so yum won't use it by default. Yum
#0 0.373 will then just ignore the repository until you permanently enable it
#0 0.373 again or use --enablerepo for temporary usage:
#0 0.373
#0 0.373 yum-config-manager --disable <repoid>
#0 0.373 or
#0 0.373 subscription-manager repos --disable=<repoid>
#0 0.373
#0 0.373 5. Configure the failing repository to be skipped, if it is unavailable.
#0 0.373 Note that yum will try to contact the repo. when it runs most commands,
#0 0.373 so will have to try and fail each time (and thus. yum will be be much
#0 0.373 slower). If it is a very temporary problem though, this is often a nice
#0 0.373 compromise:
#0 0.373
#0 0.373 yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
#0 0.373
#0 0.373 Cannot find a valid baseurl for repo: base/7/x86_64
#0 0.373 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
#0 0.373 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
昨天刚安装完成docker的时候还是可以使用的,今天再用的时候就出现这个问题了(中间服务器是否重启不太清楚) 。
最后通过以下方法解决:原因是nameserver的问题
resolv.conf
文件,增加nameservervim /etc/resolv.conf
nameserver 8.8.8.8
nameserver 114.114.114.114
chattr +i /etc/resolv.conf //resolv被锁定,即使root也不能修改
chattr -i /etc/resolv.conf
systemctl restart NetworkManager
转载请注明出处: https://chrunlee.cn/article/docker-build-yum-error.html