Every time you restart your computer, you run docker start mongo, and then you enter the Mongo container through docker exec -ti mongo mongo find that the data in the Mongo container is gone. I want to know how to backup the data in the Mongo container. Just like you can export the data using mongoimport locally, because I just got in touch with docker, I hope the great gods can help me out. Thank you very much.
I personally recommend using -v, just mount the data directory
For example, mysql, I use -v to mount mysql data to data/mysql, and the data will not be lost.
If you need backup, you can use the backup container dedicated to mongo client to back up the data after link -v mount backup to the local.