When building a docker image, I'm dumping an external db on a directory inside my container using mongodump, then I start a mongodb and execute a restore (mongorestore). Everything seems to works fine when seeing the log. My goal is to deliver docker image containging data in the database, that could be launched with prepopulated data. This way my end user can "play" with it along with a web app. Notice that I am wondering if the web app could update this data .. Losing the data after the container is stopped is not a problem in my use case.
Here the complete dockerfile
FROM mongo
RUN mongodump --verbose --uri="mongodb://....." --out=./izidump2
RUN mongod --fork --dbpath /data/db --logpath /var/log/mongodb.log; \
mongorestore --uri="mongodb://localhost:27017/mydb" --verbose ./izidump2; \
mongo --eval "db.createUser({ user: 'root', pwd: 'root', roles: ['readWrite', 'dbAdmin'] })" mydb;
Unfortunately when running the container the db does not exist.. When connecting to an instance of the running container and go to /data/db , the directory is empty . Very strange since i have restored the data inside this directory and i did not get any complaint while running the mongo restore.
What did I miss ?