【发布时间】:2021-02-16 11:31:24
【问题描述】:
我正在尝试构建一个 centos 映像,然后从无法访问 Internet 的公司网络运行基本的 yum 命令。在步骤 1 中成功获取 centos 工件后,接下来是 RUN yum update,容器尝试使用 http://mirrorlist.centos.org 加载插件,这显然行不通。它无法解析该主机,因为没有 Web 访问权限。所以,我得到了错误:
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
..."Could not resolve host http://mirrorlist.centos.org; Unknown error"
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
The command '/bin/sh -c yum update' returned a non-zero code: 1
我在 /etc/yum.repos.d 中有一个 repo 文件,其中包含描述 here 的内容。在该文件中,我有多个本地回购 URL。 [updates] 条目有一个用于 /updates 的 baseurl。当我在 Dockerfile 中执行 RUN yum update 时,容器是否应该使用此条目?容器如何知道在哪里寻找本地镜像仓库或其他仓库?
主机上的 localhost 与容器中的 localhost 是否也存在问题?
我研究了十几个 S.O.没有运气的条目。
更新:Dockerfile 到目前为止...
FROM path.to.repo/centos
RUN yum update
所以,yum 更新时会出错。
【问题讨论】:
-
如果您分享您到目前为止所尝试的内容,将会有很大帮助。你的 Dockerfile 是什么样子的?
-
为什么不简单地在有互联网连接的机器上构建图像,然后将图像移动到那里?
-
@Stefano:使用 Dockerfile 更新。上传图片不是一种选择。
-
如果我做对了,也许这会有所帮助:hub.docker.com/r/intraway/yum-repo#docker-image