After spending too much time trying to access my node server running from the docker container in the boot2docker instance, I realized that the problem boils down to the difference between exose and docker run -p.
In my Dockerfile I had EXPOSE 3001 and I was not able to access it through my host machine.
After running "docker run -p 3001: 3001 myappinst myapp" I was able to access the port.
So far, I thought that "docker run -p 3001: 3001" was essentially the same as EXPOSE 3001 in the docker file.
However, I noticed that when starting docker ps
I get the following for "EXPOSURE":
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
16341e2b9968 housemation-crawler:latest "npm start" 2 minutes ago Up 2 minutes 3001/tcp housemation-crawler-inst
(note: 3001 / tcp)
vs lower with docker run -p 3001:3001
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b14f736033c housemation-crawler:latest "npm start" 8 seconds ago Up 2 seconds 0.0.0.0:3001->3001/tcp housemation-crawler-inst
(0.0.0.0links001-> 3001 / TCP)
, - , ? ?
, ? , dockerfile, ?