0

I am attempting to build a docker image from a CentOS parent image ... and installing MongoDB. The error is happening when docker build is adding the MongoDB repo.

You can see that the error is happening because $releasever is blank for some reason.

DockerFile

FROM centos:latest
MAINTAINER "MyName" <myemail@gmail.com>
ENV container docker
RUN echo -e "\
[mongodb-org-4.0]\n\
name=MongoDB Repository\n\
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/\n\
gpgcheck=1\n\
enabled=1\n\
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc\n" >> /etc/yum.repos.d/mongodb-org-4.0.repo
RUN yum repolist all
RUN yum install -y mongodb-org

ERROR

https://repo.mongodb.org/yum/redhat//mongodb-org/4.0/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
1

You didn't escape the $, thus the variable $releasever was interpreted in your shell, instead of being inserted literally into the echo command output.

Try \$releasever.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.