connect robomongo to mongoDB docker container

后端 未结 7 1668
耶瑟儿~
耶瑟儿~ 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:38

    In your docker-compose file, you can expose a port to the host.

    For example, the following code will expose port 27017 inside the machine to the port 27018 in the host.

    app:
      image: node
      volumes:
        - /app
      ports:
        - "27018:27017"
    

    Then, if you have docker-machine installed and your machine is default, you can do in a terminal :

    docker-machine ip default
    

    It will give you the ip of your host, for example 192.168.2.3. The address of your database (host) will be 192.168.2.3 and the port 27018.

    If your docker machine is not virtual and is your OS, the address of your database will be localhost and the port 27018.

提交回复
热议问题