Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to access tomcat application on Docker VM with host(windows) IP while using docker toolbox

I am running docker on my windows system using docker toolbox. I ran tomcat container using command docker run -it --rm -p 8888:8080 tomcat:8.0. As per documentation I should be able to access tomcat using http://localhost:8888, but this is not working.

Rather, I can access the tomcat app using docker-machine ip which is http://192.168.99.100:8888.

But this is not what I need. I need to access the tomcat container app from outside my system itself, through the network. So, how do I map tomcat application to my windows host system ?

While googling around, I could see an option of port-forwarding for boot2docker vm. But, again I am not using boot2docker. I am using docker toolbox.

like image 229
urOutsourced Avatar asked Feb 26 '16 03:02

urOutsourced


People also ask

How do I make Tomcat accessible from outside?

To access the server, use its external IP address (found on the hands-on lab overview page) in the URL bar of a web browser, then append :8080 to it. Test to ensure you are unable to access the Host Manager App on the Tomcat GUI. Note: Tomcat is installed under /usr/local/tomcat9 .

How do I connect to a docker container in Windows?

To switch to Windows containers in Docker, right-click the Docker icon, and select Switch to Windows containers. To use the command line to switch between containers, run & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon .


2 Answers

Finally, I was able to find where to add the port-forwarding rule. Open the oracle VirtualBox Manager. Go to Settings-->Network --> Port Forwarding..

Here 1 rule is already available for ssh. So I added another rule for this with below configurations: HostIP:HostPort=> 127.0.0.1:9999 GuestIP:GuestPort=> :8888

So now if I invoke http://localhost:9999 , it is forwarded to => docker-machine:8888 and from there it is forwarded to => tomcatVM:8080.

like image 147
urOutsourced Avatar answered Oct 20 '22 01:10

urOutsourced


I could see an option of port-forwarding for boot2docker vm. But, again I am not using boot2docker. I am using docker toolbox.

Yes, you are using boot2docker.
Toolbox is just a bundle of boot2docker + docker-machine + kitematic.

Open your VirtualBox, and you will see a VM which, in the storage settings, is based on boot2docker.iso.

See do port-forward 8888 to your host: see "Connect to a Service running inside a docker container from outside"

VBoxManage controlvm "default" natpf1 "tcp-port8888,tcp,,8888,,8888"
VBoxManage controlvm "default" natpf1 "udp-port8888,udp,,8888,,8888"

(Replace default with the name of your docker-machine: see docker-machine ls)

like image 22
VonC Avatar answered Oct 19 '22 23:10

VonC