Docker: 容器找不到本地仓库
Docker: container cannot find local repo
我正在尝试构建一个 centos 映像,然后 运行 来自无法访问 Internet 的公司网络的基本 yum 命令。在步骤 1 中成功获取 centos 工件后,接下来是 运行 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 中执行 运行 yum update 时,容器是否应该使用此条目?容器如何知道在哪里寻找本地镜像仓库或其他仓库?
主机上的 localhost 与容器中的 localhost 是否也存在问题?
我研究了十几个S.O。没有运气的条目。
更新:Dockerfile 到目前为止...
FROM path.to.repo/centos
RUN yum update
因此,yum 更新时出错。
当您创建无法访问网络但只能访问内部网络的图像时,您必须在尝试使用它们之前更改工具配置。
使用 yum,您必须删除现有的存储库并在 RUN yum update
之前用您的存储库替换它们,类似的东西:
FROM path.to.repo/centos
RUN rm -rf /etc/yum.repos.d/*.repo
COPY myprivate.repo /etc/yum.repos.d/
RUN yum update
文件 myprivate.repo 必须在与您的 Dockerfile 相同的文件夹中定义,并且必须声明您的存储库。
此外,这个创建的图像现在可以用作您需要创建的所有其他图像的基础图像。
我正在尝试构建一个 centos 映像,然后 运行 来自无法访问 Internet 的公司网络的基本 yum 命令。在步骤 1 中成功获取 centos 工件后,接下来是 运行 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 中执行 运行 yum update 时,容器是否应该使用此条目?容器如何知道在哪里寻找本地镜像仓库或其他仓库?
主机上的 localhost 与容器中的 localhost 是否也存在问题?
我研究了十几个S.O。没有运气的条目。
更新:Dockerfile 到目前为止...
FROM path.to.repo/centos
RUN yum update
因此,yum 更新时出错。
当您创建无法访问网络但只能访问内部网络的图像时,您必须在尝试使用它们之前更改工具配置。
使用 yum,您必须删除现有的存储库并在 RUN yum update
之前用您的存储库替换它们,类似的东西:
FROM path.to.repo/centos
RUN rm -rf /etc/yum.repos.d/*.repo
COPY myprivate.repo /etc/yum.repos.d/
RUN yum update
文件 myprivate.repo 必须在与您的 Dockerfile 相同的文件夹中定义,并且必须声明您的存储库。
此外,这个创建的图像现在可以用作您需要创建的所有其他图像的基础图像。