Docker构建在运行yum install时给出“没有启用的repos”

问题描述 投票:1回答:1

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

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

我创建了这个最小的dockerfile:

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

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

编辑:基于以下答案,我现在可以停靠将repo文件添加到图像中,并修复上述错误。但我得到了这个:

--> 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
docker yum
1个回答
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
热门问题
推荐问题
最新问题