Accessing Apache2 Residing Inside Docker Container from Host Machine Web Browser

Accessing apache2 residing inside Docker container from Host machine web browser

Problem 1: Apache default port

2375 port is not the apache default port, it is the docker daemon default port, the command shall be

docker -t -i -p 49200:80 [image-id]

Problem 2: port in different machine

49200:80 This is the mapping from internal port 80 to docker host 49200, the docker host is actually your virtual box VM (guess is your boot2docker shell)

In your virtual box VM console, you can

curl localhost:49200

The picture "Port Forwarding rules" are helping your port forward to your virtualbox host, for you it is MacOS, where you mapped 49200 to MacOS 49200 as well

So in your MacOS shell console, you can also

curl localhost:49200

If you know the virtualbox VM (docker host) IP address, for example it is 192.168.59.103 as default for boot2docker, then you can

curl 192.168.59.103:49200

If you want to access the apache docker container via 172.17.0.7, remember this is the private network inside, you need to start another container like

docker -t -i busybox bash
# curl 172.17.0.7:80

Summary

docker -p is port forwarding your internal port to docker host
"Port forwarding Rules" in virtualbox setting is port forwarding your VM port to VM host

  • apache docker container: 172.17.0.7:80
  • docker host=virtualbox VM: 192.168.59.103:49200
  • virtualbox host=MacOS: xxxx:49200

Can't connect to ActiveMQ Console running in Docker container

Got it to work!

For those having the same issue, I resolved it by changing the IP address in jetty.xml from 127.0.0.1 to 0.0.0.0. I am now able to connect to my containerized AMQ instance from my host OS.



Related Topics



Leave a reply



Submit