简体   繁体   中英

how to install mongo-org-tools in centos docker container using dockerfile?

I want to have mongo-org-tools installed in my container because I want to use the tools like mongorestore and mongodump inside my container.

As the documentation of mongodb suggests, to add a repo file in conf folder which is required in CentOS. I tried doing this with dockerfile but it didn't get executed.

Is there any way of doing this via dockerfile or am i doing something wrong?

Dockerfile :

FROM centos

# Create app directory
WORKDIR /usr/src/app

# RUN adduser -G root node

#ENV http_proxy http://172.26.25.4:8080/
#ENV https_proxy http://172.26.25.4:8080/

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
COPY SmallTalkWorkspace*.json ./
COPY bin ./bin
COPY helpers ./helpers
COPY src ./src

ADD ./mongodb-org-4.0.repo /etc/yum.repos.d/

 RUN yum -y update && \
     yum -y install epel-release && \
     yum -y install nodejs npm && \
     yum -y install mongodb-org-shell mongodb-org-tools && \
     yum clean all && \
     mkdir -p /var/lib/mongo && \
     chown -R mongod:mongod /var/lib/mongo

VOLUME ["/var/lib/mongo"]

RUN ["/usr/bin/mongod", "--dbpath", "/var/lib/mongo"]

EXPOSE 5000
# USER node

CMD ["npm", "start"]

mongodb-org-4.0.repo

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

您还需要安装 mongodb-org 包来创建用户。

You need to do something like this:

FROM centos:7.6.1810

WORKDIR /usr/src

RUN curl -sL **rpm nodesource url** | bash - && \
    yum install wget -y && \
    wget **rpm URL** && \
    yum localinstall mongodb-org-tools-4.0.15-1.el7.x86_64.rpm -y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM