Windwos 7 connecting to Apache Tomcat in a docker container

http://docs.docker.com/mac/started/
So you have your docker container running an apache tomcat image and you want to connect to it using your browser.
$docker run -d -P tomcat:8-jre8
$docker ps
Under ports it tells you this
0.0.0.0:32768->8080/tcp
It means that the docker image has tomcat running on 8080 and it is routed to port 32786 on the host. At this point most docker examples say you just pop in the port into your browser and it will work. That is true when your host runs linux, but on windows/mac it is slightly different. Let's explore how docker runs on a windows box.
Docker on Windwos/Mac

We have Windows sitting on the bare metal running Virtual Box and inside virtual box the default VM is the one that executes the docker commands.
Upon closer inspection of the VM settings you can find that it has two network interfaces a NAT-ed connection that allows the default VM to access the internet for updates or to download docker images from the hub and a Host only network interface that allows the host to access the default VM.
That is the reason for Docker Tools installing virtual box on your windows host. The quick start terminal creates the default VM when started first time and all your docker commands and images will run inside that virtual machine.
Back to the original question how do you find out about the address the you need to put into the browser's address bar?
$docker-machine ip default
192.168.99.100

Visiting 192.168.99.100:32768 with your favorite browser reveals the tomcat default page.

Comments

Popular posts from this blog

The biggest java security vulnerability of 2021