Docker构建错误没有启用的存储库

时间:2015-12-13 06:59:51

标签: docker yum centos7

在Centos7.1 Docker主机上:我正在使用具有命令

的Dockerfile构建一个docker镜像
RUN yum -y install deltarpm yum-utils --disablerepo=*-eus-* --disablerepo=*-htb-*     --disablerepo=*-ha-* --disablerepo=*-rt-* --disablerepo=*-lb-* --disablerepo=*-rs-* --disablerepo=*-sap-*

在运行docker build命令期间:docker build -t <image>,我收到错误:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 You can enable repos with yum-config-manager --enable <repo>

我该如何解决这个问题?我是否还需要在docker中启用yum repo?

(请注意,我可以在Docker主机中安装这些软件包)

1 个答案:

答案 0 :(得分:2)

在Dockerfile中使用yum (the Yellowdog Updater, Modified)与您的主机CentOS无关 它与您的Dockerfile(FROM xxx)使用的基本映像有关。

重要的错误信息是:

There are no enabled repos.

您可以在&#34; RHEL 7 - Solution to "There are no enabled repos" message&#34;

中查看手动解决方案
  

如果您只是想在不需要更新Red Hat订阅的情况下玩游戏并安装软件,您可以安装下载的redhat ISO映像并将其作为默认本地存储库并能够安装软件。
  要启用本地存储库并因此克服There are no enabled repos,首先安装REHL7 iso映像:

[root@rhel7 ~]# mkdir /media/rhel7-repo-iso
[root@rhel7 ~]# mount /dev/cdrom /media/rhel7-repo-iso/
mount: /dev/sr0 is write-protected, mounting read-only

虽然Dockerfile / docker镜像不支持。

最好使用不需要任何订阅模式的基本映像。例如:

FROM fedora
RUN yum update -y
RUN yum install -y httpd

同样,这与您的主人无关。

OP在Red Hat Enterprise Linux Atomic Host 7 Getting Started Guide

之后提及

该指南明确包括:

  

要启用软件更新,您必须注册Red Hat Enterprise Linux Atomic Host安装   这是通过subscription-manager命令完成的,如下所述   如果您的系统位于需要使用HTTP代理的网络上,请参阅有关配置订阅管理器以使用HTTP代理的Red Hat知识库文章。如果您希望在查看订阅记录时提供易于记忆的名称,则可以包含--name=选项。

$ sudo subscription-manager register --username=<username> --auto-attach