I have a docker container
generated from a docker image
which has mongoDB
installed. I want to export a database from my local machine and import it into that docker container
.
What're the steps for that?
I tried to export the whole db by mongodump
and then copy the dump file into the container with docker cp
. But feels like that's not the correct way.
Thanks in advance.
You don't need to copy the file. As long as you can access mongo on a port that's open, just use mongorestore from the comfort of your local machine, eg
mongodump --uri 'mongodb://localhost:27017/yourdatabase' --archive=<your file> --gzip
mongorestore --uri 'mongodb://remotehost:27017/yourdatabase' --archive=<your file> --gzip
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.