0

I'm trying to bring up a node server up from docker. Here's how we built the docker image.

Step 1/6 : FROM node:carbon
 ---> 4f01e5319662
Step 2/6 : WORKDIR /usr/src/app
---> Using cache
---> 2a1ba8949c20
Step 3/6 : COPY package*.json ./
---> Using cache
---> 2a42784819a8
Step 4/6 : RUN npm install
---> Using cache
---> b54763a7afba
Step 5/6 : EXPOSE 3002
---> Using cache
---> 50a96a437e52
Step 6/6 : CMD [ "npm", "start" ]
---> Using cache
---> 2963362f9224
Successfully built 2963362f9224
Successfully tagged sf2backend:latest

Started image like

docker run -it -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 3002:3001 --rm sf2backend

Please note here that I'm port mapping from 3002 to 3001 (Server is listening on 3001)

And I also made the entry for server ip and host like this on server.js

https.createServer(options, app).listen(3001,'0.0.0.0');

IP tables seem to be reflecting my mapping just fine.

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE 
match dst-type LOCAL

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  0.0.0.0/0           !127.0.0.0/8          ADDRTYPE 
match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
MASQUERADE  all  --  172.18.0.0/16        0.0.0.0/0           
MASQUERADE  tcp  --  172.17.0.2           172.17.0.2           tcp dpt:3001

Chain DOCKER (2 references)
target     prot opt source               destination         
RETURN     all  --  0.0.0.0/0            0.0.0.0/0           
RETURN     all  --  0.0.0.0/0            0.0.0.0/0           
DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3002 to:172.17.0.2:3001

But I'm still not able to view the app at https://localhost:3002

No response from the server and no errors on the server log.

Naveen Karnam
  • 433
  • 2
  • 9
  • 26
  • 1
    can you curl the port 3001 from inside the container? – László Stahorszki Feb 07 '19 at 09:32
  • 1
    did you try with HTTP http://localhost:3002 If that not working, run `docker exec` and run `curl http://localhost:3001` inside the container and check if you are getting a reponse – Nijo Feb 07 '19 at 09:40
  • Needed to use "curl -k". Unsafe visit because of https certificate on localhost. That solves it. Able to access the app. Browser was showing up "Not safe to visit" window. That caught be unaware! Thanks for the suggestions! – Naveen Karnam Feb 07 '19 at 13:25

0 Answers0