Hi @sdetweil,
docker-machine env default
Docker_host=“tcp://192.168.99.100:2376”
I am using winodws 8.
I developed one sample application using (mean stack technology). I want to run this application in all environment(in every where also). So I start to use docker to run my sample application. for that I have built , push the image into docker using (docker quickstart terminal). Now when I run that application in docker by docker run nitikishu/samplenodejs command I am getting following message:
> $ docker run -p 8088:8088 nitikishu/samplenodejs
> sampleproject@1.0.0 start /C:Usersuser2Sample
> node server.js
> server running on port 8088
> Press CTRL-C to stop
> MongoDB connection error. Please make sure MongoDB is running.
in my application I gave mongodb path like this:
MONGODB_URI=mongodb://192.168.99.100:27017/sample_DB
App_PORT = 8088
I want to access my system database(I am 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/sample_DB
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 Db which ip address I should give?
yesterday you said to bind all ip in mongod.config file. I done that by below code
mongodb.cfg file (this file is in mongodb installed path of my local windows system c:mongodb/bin/mongod.cfg)
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
net:
bindIp: 0.0.0.0
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
Here, I included the steps which I followed to run the application in docker
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
user2@system2 MINGW64 ~
$ cd sample
user2@system2 MINGW64 ~/sample
$ docker --version
Docker version 17.05.0-ce, build 89658be
user2@system2 MINGW64 ~/sample
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v17.06.0-ce
user2@system2 MINGW64 ~/sample
$ docker build -t nitikishu/samplenodejs .
Sending build context to Docker daemon 48.7MB
Step 1/7 : FROM node:carbon
---> b87c2ad8344d
Step 2/7 : WORKDIR C:\Users\user2\Sample
---> Using cache
---> 3880524e00d9
Step 3/7 : COPY package*.json ./
---> Using cache
---> 6e116b22c908
Step 4/7 : RUN npm install
---> Using cache
---> a31a7a85f633
Step 5/7 : COPY . .
---> 7124ff43c59c
Removing intermediate container c8e8c639d7f0
Step 6/7 : EXPOSE 8088
---> Running in 4cd031953ed5
---> 9c252b8cb2c2
Removing intermediate container 4cd031953ed5
Step 7/7 : CMD npm start
---> Running in 19910c6a969f
---> 36e4e33d1466
Removing intermediate container 19910c6a969f
Successfully built 36e4e33d1466
Successfully tagged nitikishu/samplenodejs:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' p
ermissions. It is recommended to double check and reset permissions for sensitive files and directories.
user2@system2 MINGW64 ~/sample
$ docker push nitikishu/samplenodejs
The push refers to a repository [docker.io/nitikishu/samplenodejs]
4638b36f4098: Pushed
bc17d0d0ec47: Layer already exists
d228ef051c7d: Layer already exists
0697092f077d: Layer already exists
092504c250f7: Layer already exists
299e6ab856be: Layer already exists
50599c766115: Layer already exists
d4141af68ac4: Layer already exists
8fe6d5dcea45: Layer already exists
06b8d020c11b: Layer already exists
b9914afd042f: Layer already exists
4bcdffd70da2: Layer already exists
Head https://registry-1.docker.io/v2/nitikishu/samplenodejs/blobs/sha256:36e4e33d1466f119410498bd88b9a33d51c4792cbd7a2810dbf455e8ca8f4ce4: net/http: TLS handshake timeout
user2@system2 MINGW64 ~/sample
$ docker pull nitikishu/samplenodejs
Using default tag: latest
latest: Pulling from nitikishu/samplenodejs
Digest: sha256:7db75ca39cf597ac92a5fa3f459d5315f8909c6042e14a491238026bfdd24892
Status: Downloaded newer image for nitikishu/samplenodejs:latest
user2@system2 MINGW64 ~/sample
$ docker run -p 8088:8088 nitikishu/samplenodejs
> sampleproject@1.0.0 start /C:Usersuser2Sample
> node server.js
server running on port 8088
Press CTRL-C to stop
MongoDB connection error. Please make sure MongoDB is running.
user2@system2 MINGW64 ~/sample
$