[英]Import a Mongo Database into a Docker Container
I have a docker container
generated from a docker image
which has mongoDB
installed.我有一个
docker container
,它是从安装了mongoDB
的docker image
生成的。 I want to export a database from my local machine and import it into that docker container
.我想从本地机器导出数据库并将其导入到
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
.我尝试通过
mongodump
导出整个数据库,然后使用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
只要您可以在打开的端口上访问 mongo,只需在本地机器上舒适地使用 mongorestore,例如
mongodump --uri 'mongodb://localhost:27017/yourdatabase' --archive=<your file> --gzip
mongorestore --uri 'mongodb://remotehost:27017/yourdatabase' --archive=<your file> --gzip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.