MongoDB docker container losing data overnight.
I have a MongoDB docker container running in my linode instance. Each night, my MongoDB docker container seems to be automatically destroyed. It is then recreated when I log in. Hence I lose my persisted MongoDB docker-volume database. Why ??
1 Reply
From my limited understanding of Docker, I can see 2 issues here:
- why is your container being destroyed automatically
- why is your data not persisted?
How are you launching your Docker container?
When you say it is destroyed overnight, is it when you logout in an evening, or at a specific time? The container will exit when the launch process ID (PID 1) terminates, so is there something happening that kills this process?
Do the docker logs show anything helpful?
Do you mount the MongoDB data directory in the container back to a directory on your Linode? If so, does your initial command when you launch the container perform any initialisation of that directory? (My MongoDB knowledge is even less than my Docker, but I’m thinking of MySQL and PostgreSQL where you have to initialise the data directory with a default set of data files before it can be used. Does MongoDB do something similar, and is this being run each time the container starts?)