Localhost or IP address of docker VM?

Hi whenever I install and image and try to run it, I can never access it via localhost or via the VM IP Address, what am I doing wrong?

Also in my curiosity i thought i try out docker for windows, (using windows 7) but i got to admit its not as straight forward as it could be, so much out of date information, e.g. installing NodeBB from here does not install (download image), but using the commands from NodeBB it downloads/installs image, how does that make any sense?

If you start a container that is running a process such as a web server, when you start that container you need to specify what ports to publish from the container to the host, for example
docker run -p 8888:8080 tomcat
this publishes port 8080 from the container to the host’s port 8888
Next, you need your host’s ip, if running on windows run:
boot2docker ip
let’s say that command returns 192.168.59.105
now pull up a browser on your local machine and you should be able to hit http://192.168.59.105:8888 and get tomcat’s default home page.

Take a look at the docker run reference, specifically the section titled “EXPOSE (incoming ports)” https://docs.docker.com/reference/run/

1 Like