Wednesday, 5 April 2017

Why am I unable to access my node.js app within a docker container?

I am running two containers on an ubuntu linux system in the microsoft azure cloud (a node.js app called eva and a postgres-db used by the app):

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
339b252e9895        eva                 "node app.js"            17 hours ago        Up 17 hours         0.0.0.0:8086->8086/tcp   eva
91a39d88c1eb        postgres            "/usr/lib/postgresql/"   19 hours ago        Up 19 hours         5432/tcp                 postgres

I exposed the node.js app on port 8086 and used the following command to start the container from the image:

sudo docker run --name eva -p 8086:8086 eva

I have opened the port for this linux server on the azure console and tried to access it but chrome shows me a connection refused error. I also tried to access it locally via curl:

sudo curl --trace curl.out localhost:8086

This is curl.out:

== Info: Rebuilt URL to: localhost:8086/
== Info:   Trying 127.0.0.1...
== Info: Connected to localhost (127.0.0.1) port 8086 (#0)
=> Send header, 78 bytes (0x4e) 0000: 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a GET / HTTP/1.1.. 0010: 48 6f 73 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a Host: localhost: 0020: 38 30 38 36 0d 0a 55 73 65 72 2d 41 67 65 6e 74 8086..User-Agent 0030: 3a 20 63 75 72 6c 2f 37 2e 34 37 2e 30 0d 0a 41 : curl/7.47.0..A 0040: 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 0d 0a       ccept: */*....
== Info: Recv failure: Connection reset by peer
== Info: Closing connection 0

I have already done the same locally on my MacOS and it was working. Additionally I deployed the app myself by moving the source files to the linux system via scp and ran the app myself on port 8085 by only using the node command; it was working, too.

Why am I unable to access my node.js app within a docker container on ubuntu?



via Mr. T

No comments:

Post a Comment