-
Notifications
You must be signed in to change notification settings - Fork 649
Mounting external working directory with data directory #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @onlybytes , I am not sure why you use an initdata file at first glance but if you comment the following lines, your container should work fine:
But if you use bind mount volume, your db path i.e I hope , that can help your need. |
Thanks @ozlerhakan I will try without binding mount volume in Dockerfile. Note: The host directory is mainly used for the storage purposes. For the reasons documented under "Where to Store Data" section of https://hub.docker.com/_/mongo/ page |
I think, this point from Docker documentation gives me the answer Volumes are initialized when a container is created. If the container’s base image contains data at the specified mount point, that existing data is copied into the new volume upon volume initialization. (Note that this does not apply when mounting a host directory.) So i can not do what i was doing.. If i need initial data then, i should let the Docker manage the storage of my database. If i want to mount host directory, then i can not have initial data. |
Yeah, that's correct 👍 (unfortunately)
|
Thanks @tianon |
Hello @onlybytes @tianon @shykes , I followed the above steps however when I run my image, it says that the mongodb service is not running. My Dockerfile: FROM ubuntu:14.04 COPY initdata.sh /opt/scripts/initdata.sh My initdata.sh: The log is like below: I am not sure how to start the service when I docker run with ports on the image. Can you please help? |
Hi,
I have to add some default data into mongo db and build a image.
I followed this thread - #64 (comment) - and understood that data wont persist in /data/db. Hence created my own data directory /data/db2. Everything works fine, but i am not able to mount the directory on the host system to the directory visible inside the container.
docker run -d -v $PWD/testdb:/data/db2 --name my_mongo_db my_mongo_image
results in error: STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db2/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminatingdocker run -d --name my_mongo_db my_mongo_image
works fine.Well,
docker run -d -v $PWD/testdb:/data/db --name my_mongo_db my_mongo_image
works fine. Unfortunately data wont be persisted in /data/db.To solve this issue, the suggestions on the web were:
Unfortunately none worked.
Here is my docker file:
Here is initdata.sh:
The text was updated successfully, but these errors were encountered: