1

Question

I have a MacBook pro, I have VirtualBox installed on my Macbook with RHEL 7.x VM ( Say VM 1 ) running. This VM 1 is headless so I have no Browser here. Inside this VM I have a docker container of RHEL plus TOMCAT

Now I want to access a Tomcat application running inside the docker container from my host MacBook pro laptop. How can I do that?

Adarsh Ravi
  • 893
  • 1
  • 16
  • 39
ragasa
  • 11
  • 2
  • I have not used VM that much but I am sure you could do SSH into the VM from the host OS. From there you could do what you want, like talking to another VM inside of it. check [this](https://stackoverflow.com/a/10532299/5757160) out for more details – scipsycho Nov 05 '18 at 11:26
  • I can SSH into VM from my host, and from the VM, I can go to the docker container hosted by the VM , however from my outer most host which is macbook, I want to access the webapp ( tomcat application ) running inside a docker continer and the docker container is hosted in a VM – ragasa Nov 05 '18 at 18:21
  • The link you have provided, helps me to do ssh to a VM from the host ... – ragasa Nov 05 '18 at 18:27
  • Unless you swap out the runtime of Docker, it's not creating VM's, it's creating containers. I'd rephrase the question to either indicate you've replaced the runtime, or be specific about docker running containers. We also need to know how you are running the containers. See [mcve]. – BMitch Nov 05 '18 at 18:58
  • @ragasa if you want to access the web application, then map the ports in such a way that when you use safari on your Mac OS to access a port it reaches the docker container running inside the VM through a series of port mapping. – scipsycho Nov 06 '18 at 02:05
  • @BMitch did you see the image .. I will rephrase my question – ragasa Nov 06 '18 at 05:20

1 Answers1

0

The tomcat application port should to mapped to RHEL 7.x VM using docker-compose or in-line command to run docker

Docker-compose:- Check this link how to link application to specific port https://github.com/thoopalliamar/Juggler/blob/master/docker-compose.yml

in-line:-

docker run -d -p 5801:5801 -p 5802:5802 .....

With this now your application port is opened to the Virtual Machine

Now you need to open the VM PORTS to the Mac OS which you are using for that procedure follow the given link below as it explains in a detailed way

https://gist.github.com/odan/48fc744434ec6566ca9f7a993f4a7ffb

Now, you should be able to access the application.