I am using docker image for mongo. I changed the directory where I want to save my data inside the mongo.conf file:
dbpath=/mnt/sda1/data/db/
Also I am using docker-compose to create my development environment:
mongo:
image: mongo
ports:
- 27017:27017
volumes:
- $HOME/Desktop/development/mongo/data/:/mnt/sda1/data/db/
- $HOME/Desktop/mongo/config/mongod.conf:/etc/mongod.conf.orig
command: mongod --smallfiles
When I go inside my mongo container and I check the /mnt/sda1/data/db directoy, it is empty and then go to /data/db and the data is here.
I don't understand why the data isn't inside the directory /mnt/sda1/data/db is I defined it has the dbpath for mongo configuration file.