

Don't worry, we will get it back soon.ĭocker exec -i some-mongo sh -c "mongorestore -archive" < /some/path/on/your/host/all-collections.archiveĭocker exec -i some-mongo sh -c "mongorestore -archive" <.
DOCKER MONGODB COMPASS ARCHIVE
Once you have the archive created, you can delete your test database. Generic command :ĭocker exec some-mongo sh -c "exec mongodump -d -archive" > /some/path/on/your/host/all-collections.archiveĭocker exec some-mongo sh -c "exec mongodump -d petstore -archive" >. In this case, mongod is running inside the a docker container, so to run mongodump we will need the exec command. This can be achieved by generating a dump of the database, and later on restoring it.

Ideally you would want all of them to have the same base test data. Now let's say you are working as part of a team, and your other members needs to be able to run the database for development as well. Once that is done, it should look similar to this image Generate dump archive Once Inside, you can create a new database on the left hand side, add a starting collection to the database, then select the database and add one document to it. In the future you would want to add a database user, and in that case you would change the authentication when connecting. You can use the default settings right now. Once installed and opened, just open MongoDB Compass, and click Connect. To more easily work with data inside MongoDB, use the graphical interface called MongoDB compass, you can get it here. However I would recommend adding a port mapping, which will connect the container's port 27017 ( mongodb's default port ) to your port 27017, which will more closely replicate having mongo installed locally.ĭocker run -name some-mongo -d -p 27017:27017 mongo:latest Compass To run the container with name some-mongoĭocker run -name some-mongo -d mongo:latest

We will be working with the Docker Mongo image
