Docker in practice: export a mongodb collection

Question

You starts a remote terminal in a linux machine that has network access to a MongoDB instance with ip 192.1.1.10. Now you need to export a collection 'logs' using mongoexport tool. You do not have SSH access to that MongoDB machine. And, you are not allowed to install anything in this terminal. You can use the docker which is already installed in the machine.

Answer:

docker run \ # start docker
--rm \ # remove the container when command finished
--network host \ # use host network in order to connect to remote Mongo, otherwise, network is isolated by default
mongo \ # use latest mongoDB image
mongoexport --collection logs --host 192.1.1.10 --port 27012 \ # run the tool
> logs # pipe the output collection jsons to a file
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,499评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,130评论 0 23
  • The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
    网事_79a3阅读 12,451评论 3 20
  • TGI= 某指标在细分人群的占比/该指标在总体人群的占比*100 TGI>100 说明该指标在细分人群的表现高于总...
    dataliuliu66阅读 1,393评论 0 1
  • 今天我第一个来作文班就发现了几条小金鱼,它们真可爱了。我想到了一个谜语:凸眼睛,宽嘴巴,肚子圆,尾巴大,住...
    嘉益2阅读 190评论 1 0