connect robomongo to mongoDB docker container

后端 未结 7 1648
耶瑟儿~
耶瑟儿~ 2021-02-02 17:11

I\'m running a NodeJS App with docker-compose. Everything works fine and I can see all my data by connecting to Mongo inside container. But when I connect to RoboMo

7条回答
  •  走了就别回头了
    2021-02-02 17:44

    There is another way. You can

    1. SSH with Robomongo into your actual virtual server that hosts your docker applications (SSH tab, check "Use SSH tunnel" and complete the other fields accordingly)
    2. Now ssh into the same machine in your terminal.
    3. docker ps should show you your MongoDB container.
    4. docker inspect will print out complete information about that container. Look for IPAddress in the end, that will give you the local IP of the container.
    5. In the "Connection" tab in Robomongo use that container IP to connect.

    Another sidenote: Make sure that you don't expose your mongodb service ports in any way (neither Dockerfile nor docker-compose.yml), cause that will make your database openly accessible from everywhere. Assuming that you don't have set up a username / password for that service you will be scanned and hacked soon.

提交回复
热议问题