0

I am a newbiew to Docker. I am using Mac hence have installed Docker in HortonWorks Sandbox Virtual Box.

I am trying to create 2 containers out of a Ubuntu base image. One container runs nodejs on it and other with mysql.

I am able to create a container and it lists under Docker ps, but when I try to specify port for that container, it doesn't show me any error, but the port is not getting set.

Command used to add port to a running container:

docker run -p 8080:8080 nodejsapp

where node jsapp is my Image name of 1 container.

Any help would be really appreciated. Thanks.

Ann
  • 15
  • 7
  • Have you specified `EXPOSE 8080` in your Dockerfile? – loganfsmyth Feb 14 '15 at 00:18
  • @loganfsmyth: if I understand this correctly, `EXPOSE` is a 'subset' of the `-p` argument listed by the OP so that shouldn't be the cause in this case, right? ie if you specify `-p` that exposes and published the ports. – Abdullah Jibaly Feb 14 '15 at 03:13
  • Yup, you are right, my mistake. Could you elaborate on what command you are running to start both your containers, the output of docker ps, and elaborate on what makes you say that the port is not being set? – loganfsmyth Feb 14 '15 at 03:16
  • When I created a new image, the issue was resolved. weird.. :(.. Thanks everyone for your replies.. – Ann Feb 15 '15 at 03:27

1 Answers1

0

It's hard to say without seeing your Dockerfile and without knowing what error messages you're seeing, but my guess is that you're not telling NodeJS what port to run on. The convention in NodeJS is to do this with the NODE_PORT environment variable:

docker run -e NODE_PORT=8080
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197