7

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.

Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
urOutsourced
  • 1,029
  • 10
  • 14

2 Answers2

8

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.

urOutsourced
  • 1,029
  • 10
  • 14
  • You don't need to use the GUI: VBoxManage *is* available. Just add the installation path of VirtualBox to your path. – VonC Mar 02 '16 at 07:20
  • And you don't need to use a different port (unless 8888 was already used on your host) – VonC Mar 02 '16 at 07:21
  • Spent hours on searching for this answer on Docker docs. The official Docs are rIdiculous in some way and this two different "Docker Toolbox / docker-machine" with VirtualBox Manager and "just Docker" without VirtualBox Manager makes research complicated. Thanks for that posting! But... `HostIP:HostPort=>127.0.0.1:9999 GuestIP:GuestPort=>:8888` only helped me to open my site on the servers local browser - not reachable by any other computer (by using the servers IP:8888). Had to leave the "source IP" blank `HostIP:HostPort =>:9999 GuestIP:GuestPort=>:8888` (like _VonC_ s commandline-solution) – emale Feb 02 '19 at 15:45
1

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)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the quick response @VonC. But VBoxManage command is not available in the Docker quickStart terminal or virtualBox VM console. Again, I am on windows7 OS and am using docker toolbox. – urOutsourced Mar 02 '16 at 03:04
  • @urOutsourced, if you also separately install VirtualBox, you can run the VBoxManage command on the VirtualBox VM that Docker Toolbox launches. – Derek Mahar Apr 12 '16 at 14:22