Laxmi Prasad
Laxmi Prasad

Reputation: 462

Import data to Docker-container's mongodb

I have mongo database that I used to use. But now I have to switch everything to docker container. while switching I am not being able to import data from local machine mongo-db to container mongo-db.

How can I import all the data from local mongodb to container's mongodb?

Upvotes: 4

Views: 3071

Answers (1)

A strategy you can follow is to use mongodump and mongorestore (refer to https://docs.mongodb.com/manual/reference/program/mongodump/ )

Mongodump and restore are preferred over the export and import variants, since the latter one use JSON and cannot preserve al BSON data-types.

Depending on how you manage the database file storage in your container, you either make the 'dump' available on a file-share that is mounted by the container or make it available in a container volume. That information can be found here: https://docs.docker.com/samples/library/mongo/

Upvotes: 2

Related Questions