Docker mongodb - add database on disk to container -
i running docker on windows , have database entries on disk @ c:\data\db.
i want add database container. have tried numerous ways failed.
i tried: docker run -p 27017:27017 -v //c/data/db:/data/db --name mongodb devops-mongodb
in dockerfile have:
run mkdir -p /data/db volume /data/db
but doesn't add current database on disk container. creates fresh /data/db directory , persists data add it.
the docs here https://docs.docker.com/userguide/dockervolumes/ under 'mount host directory data volume' told me execute -v //c/data/db:/data/db isn't working.
any ideas?
you're using boot2docker (which runs inside virtual machine). boot2docker uses virtualbox guest additions make directories on windows machine available docker running inside virtual machine.
by default, c:\users
directory (on windows), or /users/
directory (on os x) shared virtual machine. outside directories not shared virtual machine, results in docker creating empty directory @ specified location volume.
to share directories outside c:\users\
virtual machine, have manually configure boot2docker share those. can find steps needed in virtualbox guest addition section of readme;
if other path or share desired, can mounted @ run time doing like:
$ mount -t vboxsf -o uid=1000,gid=50 your-other-share-name /some/mount/location
it important note in future, plan have share created in virtualbox "automount" flag turned on mounted during boot @ directory of share name (ie, share named home/jsmith automounted @ /home/jsmith).
please aware using virtualbox guest additions have bad impact on performance (reading/writing volume slow). fine development, should used caution.
Comments
Post a Comment