3

I am new to docker. I built one application to run in docker. I am running the application in 192.168.99.100:8088 docker machine IP address. But I am unable to connect with MongoDB of my local system db.

In my application I gave mongodb path like this:

MONGODB_URI=mongodb://192.168.1.88:27017/sampledb   (192.168.1.88is my system ip address it is not static)
App_PORT = 8088

I want to access my system database (I'm using the database named as pmsdb) I want to access that db with the sample application in docker.

I dont know how to connect mongodb database into that docker. Which path should I give also I don't know. Because When I run the application in my system I will use mongodb path="monogdb://localhost:27017/sampledb If I use the same path in docker built application It is not working.

Using docker -machine ip address 192.168.99.100:8088 I am running my project. But my system database(sampledb) which ip address I should give?

How to connect my mongo db with docker container (samplenodejs)

Now How to connect my local db into samplenodejs application which is running in docker.

Mongodb version :3.4.2 
ip address of mongodb: 127.0.0.1:27017
N15
  • 305
  • 2
  • 4
  • 17
  • Possible duplicate of [Forward host port to docker container](https://stackoverflow.com/questions/17770902/forward-host-port-to-docker-container) – Adam Barnes Jan 24 '18 at 14:28
  • `docker run --net="host"` should help. This will make the `localhost` inside the container point to the docker host. – Faizuddin Mohammed Jan 25 '18 at 06:25
  • Referred from https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – Faizuddin Mohammed Jan 25 '18 at 06:26
  • docker run --net="host" . Here what is the host what value it has – N15 Jan 25 '18 at 07:50
  • i am using windows docker host. – N15 Jan 25 '18 at 07:51
  • I am not using static ip address to connect the database. I need to connect dynamic ip address for mongodb database. My application is running on docker container(192.168.99.100:8088). my mongodb is running in my local server machine(192.168.1.88 my system ip address) when I try to give this machine mongodb as path to that application running in container is not working. – N15 Jan 30 '18 at 06:04

0 Answers0