I'm trying to run the a docker-compose operation which spawns up a Redis and MongoDb instance and which (should) provide the MongoDb instance with a data-file from the host pc through the volumes specification.

I can successfully boot up the container using the following docker-compose.yml:

redis:
  image: redis
  ports:
   - "6379:6379"
mongo:  
  image: mongo:latest
  volumes:
    - ./data/db:/data/db
  ports:
    - "27017:27017"
  command: --rest

assuming it should 'mount' the directory data/db of which the data dir is next to the docker-compose.exe file.

enter image description here

I can connect to both Redis and MongoDb, but a simple query on a collection performing a count() returns 0 (which should contain data). Which leads me to believe that the mounting of the volumes property isn't working.

If I check the file structure on the container I don't see a /data folder... Am I missing something here... Thanks for any lead!

enter image description here

share|improve this question
up vote 1 down vote accepted

What you are showing is the filesystem of boot2docker, the TinyCore-based Linux host which runs the docker daemon.
It is not:

And that will only works if your files are in C:\users\... or /Users/..., which is the only host folder mounted by VirtualBox in the Linux VM.

To check if the mount has taken place, do a docker exec mongo bash, to open a bash in that container and check ls /data.

share|improve this answer
    
ok cool, I was able to see through Kitematic that a volume was being mounted, however it was not pointing to the local directory that I specified. The fact that it needs to be in a c:\users directory solved it. I moved everything there and now it mounts the correct volume. Too bad that the data can't be loaded which means the container can't be started... (Text file busy: "/data/db/journal/j._0") – Ropstah Jan 24 '16 at 20:17
    
@Ropstah Note that you can mount other folders in boot2docker (stackoverflow.com/a/33998695/6309: see also the other answer on that same page) – VonC Jan 24 '16 at 20:19
    
Thanks for clearing up. I think I see the error and it is related to permissions on the /data/db folder. Somehow the container is unable to write to those files... I'm gonna mark your answer as answer, but hopefully you can point me out where those permissions should be set... – Ropstah Jan 24 '16 at 20:28
1  
    
Thanks for your link suggestions. However I'm not really sure as to what I need to do to fix it. I cannot start up my container due to the permissions. Only thing I can imagine is doing some chown operation on the host (which is Docker right? Not my local pc running the docker VM?) where the /data/db folder resides for the mongodb:mongodb user/group or something? – Ropstah Jan 24 '16 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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