I am brand new to docker and I am attempting to follow the node js tutorial that they have listed: https://docs.docker.com/examples/nodejs_web_app/
I follow this tutorial and everything seems to work great until the test portion and I can't curl to the port specified.
$ curl -i localhost:49160
curl: (7) Failed to connect to localhost port 49160: Connection refused
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21e727bc5a7d username/docker-test "node /src/index.js" 13 minutes ago Up 13 minutes 0.0.0.0:49160->8080/tcp gloomy_heisenberg
$ docker logs 21e727bc5a7d
Running on localhost:8080
$ docker exec -it 21e727bc5a7d bash
[root@21e727bc5a7d /]# netstat -tulpn
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1/node'
Not sure if I am confused about something or how to troubleshoot this, any ideas?
Docker allows you to package an application with its environment and all of its dependencies into a "box", called a container. Usually, a container consists of an application running in a stripped-to-basics version of a Linux operating system.
This is the solution:
Run you application like this:
docker run --rm -i -t -p 49160:8080 <your username>/centos-node-hello
An output should come saying listening to port 8080. This means that the application is running
Open another docker CLI terminal and type:
docker-machine ls
You will see and IP address and a port. Example: 192.168.99.100:<some-number>
Go to a browser and type the IP address and the exported port number.
In this case, 192.168.99.100:49160
, and your website should come on.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With