Reputation: 17804
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.
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!
Upvotes: 2
Views: 4674
Reputation: 1325017
What you are showing is the filesystem of boot2docker, the TinyCore-based Linux host which runs the docker daemon.
It is not:
./data/db
is (it should be right beside the docker-compose.yml
file)/data/db
is: it should be mounted in the mongo containerAnd 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
.
Upvotes: 2