Docker Community Forums

Share and learn in the Docker community.

Calculating IP Addresses


(Shuntera) #1

Having had some trouble with permissions running Linux based images inside Docker for Mac, I wanted to try to have a Virtualbox Linux VM running on my mac and then run Docker inside that.

Which I have done and the Docker apps within that seem to work OK.

What i would like to figure out is what IP address and port I need to use on my web browser to get to the web application which sits inside Docker which sits inside the Virtualbox VM.

So for example nzbget uses port 6789 and that container is running, how do I expose that to my mac web browser.

nzbget on port 6789 -> Docker -> Virtualbox -> Mac


(David Maze) #2

The VM’s IP address; the first port number you specified in the docker run -p option.

If you provisioned the VM using docker-machine, its IP address is usually 192.168.99.100, but docker-machine ip default will tell you for sure.


(Shuntera) #3

I didn’t use docker-machine to provision so can’t use that.

I used vagrant to install the Ubuntu image, and when I used ‘vagrant up’ the output showed that the 127.0.0.1 IP address was active on port 2222.

So in my ssh app (VSSH) I pointed at 127.0.0.1 on port 2222 using username and password both as vagrant and I got the shell. Ok so I am thinking initially that should then work if I bring up a web server in the Ubuntu VM I should be able to get to that hia http://127.0.0.1 if that address worked for ssh.

So I did a ‘sudo python -m SimpleHTTPServer 80’

And then I did a ‘curl http://127.0.0.1’ and that worked, I got the index.html content I had created.

However that didn’t carry out to my Mac, though 127.0.0.1 worked for ssh, it didn’t work in Firefox. Couldn’t connect.

Next I tried ifconfig and looked at eth0 - it showed an IP address of 10.0.2.15, well that worked with curl inside the Linux VM but again, as expected did not work in Firefox on the Mac host.

I’m kind of stuck right now. This isn’t even a Docker question at this point, so I am sorry about that.

ETA: Got further, I looked at the networking section of Virtualbox and pressed the Port Forwarding button. Seeing that it had set up a port forward for port 22 (guest) to port 2222 (host) for ssh, I added a port forward for port 80 (guest) to port 8083 (host).

After saving that I could get my index.html contents by going to http://127.0.0.1:8083 in Firefox on my Mac.

Getting there!!!

Next to complicate it by running Docker!

ETA, got nzbget docker container up and running using the port forward again, I forwarded port 6789 to 8084 and can bring up nzbget on the Mac at http://127.0.0.1:8084

Then did the same with sonarr coming up on http://127.0.0.1:8085

Now the hard part - to tell sonarr to use nzbget as the download client. If in the sonarr config settings I tell it to use host as 127.0.0.1 and port as 8084 I get the error:
“Test was aborted due to an error: Unable to connect to NzbGet. Error: ConnectFailure (Connection refused)”

So I then tried 127.0.0.1 and port 6789 - no joy. I also tried
localhost 6789
localhost 8084

Didn’t work

Next I ran ‘VBoxManage guestproperty enumerate vagrant_default_1478801951095_64307’ to see what address that might throw out - so I then tried:
10.0.2.15 8084 - didn’t work!

10.0.2.15 6789 - SUCCESS!!!

So inside vagrant in the Linux VM while I can get to the individual containers via the 127.0.0.1 address and the port forwarded port on Firefox on my Mac, to get the two containers to talk to each other I have to use that 10. address and the original, not port forwarded, port.

Still not sure of the logic behind it, but it is working now, so I hope that helps someone else.