I am developing this application with my team, and we would like to test our code in development without using our production database.
It should all be done locally, so how can I run a new mongodb docker container and copy all data of our database to this new mongo container?
Basically I'd like to run a docker-compose and Dockerfile command that would create (if not already there) a new mongo container (raw, with no data), connect to our atlas URI, copy all the data of a database and paste it to this new container. If the container is already present, the script should drop the database and copy/paste it again.
Is this doable?
You should be able to just spawn a fresh MongoDB container with a persistent volume, then use the mongodump
and mongorestore
utilities to re-import the data into the local mongo container.
for example:
mongodump --archive=dump.db.gz --gzip --host=cloudyhost.atlas.whatever
mongorestore --archive=dump.db.gz --gzip