Docker 构建在运行 yum install 时提供"There are no enabled repos"



我正在尝试dockerfy这里描述的安装指南:

https://docs.opsmanager.mongodb.com/current/tutorial/install-simple-test-deployment/

我创建了这个最小的码头文件:

FROM registry.access.redhat.com/rhel7/rhel:latest
RUN yum install -y mongodb-org mongodb-org-shell

但是当我构建它时,我得到:

$ docker build . -t my-image
Sending build context to Docker daemon  22.53kB
Step 1/2 : FROM x.y.z:1234/rhel7/rhel:latest
 ---> 6979ec30598b
Step 2/2 : RUN yum install -y mongodb-org mongodb-org-shell
 ---> Running in d696383b761d
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>

从上面的指南中,我需要首先添加:

echo "[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" | sudo tee /etc/yum.repos.d/mongodb.repo

这到我的码头工人文件。关于如何做到这一点的任何输入/示例?我想我基本上需要将上面的文本块复制到图像上的/etc/yum.repos.d/mongodb.repo文件中?

编辑:根据下面的答案,我现在可以docker 将存储库文件添加到映像中,并修复了上述错误。但我得到这个:

--> Processing Dependency: openssl for package: mongodb-org-tools-4.0.9-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: mongodb-org-tools-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
           Requires: openssl
Error: Package: mongodb-org-server-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
           Requires: openssl
Error: Package: mongodb-org-shell-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
           Requires: openssl
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
The command '/bin/sh -c yum install -y mongodb-org mongodb-org-shell' returned a non-zero code: 1

不确定这是否与存储库信息有关。我还尝试在dockerfile中安装openssl:

RUN yum install openssl

但这给出了:

No package openssl available.
Error: Nothing to do
The command '/bin/sh -c yum install openssl' returned a non-zero code: 1

Dockerfile的同一文件夹中创建一个包含内容的文件,并将它们添加到图像中。例:

cat <<EOF > mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF

然后在您的 Dockerfile 中:

FROM registry.access.redhat.com/rhel7/rhel:latest
ADD mongodb.repo /etc/yum.repos.d/mongodb.repo
RUN yum update && 
    yum install -y mongodb-org mongodb-org-shell

相关内容

最新更新