0

I have a data file which needs to be added to the mongodb in docker. i have a docker file but i do not know how to copy my data file from local machine to mongodb docker image.

My Docker file :

FROM dockerfile/ubuntu
RUN \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && \
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && \
 apt-get update && \
apt-get install -y mongodb-org && \
rm -rf /var/lib/apt/lists/*
VOLUME ["/data/db"]
WORKDIR /data
CMD ["mongod"]
EXPOSE 27017
EXPOSE 28017

How can i add data files from my local to the mongodb using above docker file

Krishna
  • 39
  • 9
  • Possible duplicate of [How to create a Mongo Docker Image with default collections and data?](http://stackoverflow.com/questions/33558506/how-to-create-a-mongo-docker-image-with-default-collections-and-data) – xkcd149 Feb 22 '17 at 19:06

1 Answers1

0

Docker has COPY command. Firstly, make sure your date file is at the same directory with Dockerfile. Then simply add below line to your Dockerfile.

COPY your-data-file /pathInContainer

CloudStax
  • 649
  • 5
  • 6