美文网首页
Docker in practice: export a mon

Docker in practice: export a mon

作者: Star_C | 来源:发表于2019-08-25 20:59 被阅读0次

    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
    

    相关文章

      网友评论

          本文标题:Docker in practice: export a mon

          本文链接:https://www.haomeiwen.com/subject/dpukectx.html