Docker Community Forums

Share and learn in the Docker community.

Unable to browse to linux container endpoint when running on Windows using docker toolbox


(Jamiet) #1

I’m using container image https://hub.docker.com/r/alexcoppe/pyspark/ which, when I docker run on linux starts and I can successfully browse to the UI that the container presents at http://127.0.0.1:8889. The linux host is running in virtualbox upon a Windows host.

I would also like to run that same docker image on the Windows host, just so that I don’t have to use the linux VM intermediary. I am using Docker Toolbox to do this. The container starts successfully:

$ docker run --rm -it -p 127.0.0.1:8889:8889  -v $(pwd):/notebook alexcoppe/pyspark
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 08:33:57.229 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 08:33:57.248 NotebookApp] Serving notebooks from local directory: /notebook
[I 08:33:57.248 NotebookApp] 0 active kernels
[I 08:33:57.248 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8889/
[I 08:33:57.248 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

however when I browse to the same endpoint all I see is:

This site can’t be reached
127.0.0.1 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

I’m not very knowledgeable on the inner workings here other than knowing that that container image is running on a virtualbox linux VM that Docker Toolbox creates for me behind the scenes. How can I browse to the endpoint from my Windows host?
TIA


(David Maze) #2

The VM has its own IP address; docker-machine ip will tell you (it is almost always 192.168.99.100), and as always, you can access containers using the host system’s IP address, where in this case the VM is the host system.

If you run a container with -p 127.0.0.1:..., it will only be accessible from the host system and not elsewhere on the network, which in this context means other processes running on the Docker Machine VM can access it but your desktop system can’t.

Please Google “docker localhost” (or, say, “docker localhost mysql”) before you type “localhost” or “127.0.0.1” into anything. There’s a huge amount of confusion about what localhost means, and it means different things in different contexts. I’d recommend:

…if you have two containers on the same system that want to talk to each other, Docker provides a DNS setup, and the containers should be configured to use the other containers’ --names.

…if you need to access a container from outside, use -p to publish a port, then use the host system’s DNS name or IP address and the published port number.

…if you have Docker Machine (or Toolbox), then the “host system’s IP address” is probably 192.168.99.100 and is probably inaccessible from elsewhere on the network.

…in the extremely specific case of wanting to access a container running on the system you’re logged into right now, you can use “localhost”, and that is probably easier than finding out your laptop’s current IP address, but nobody else (not other computers on the network, not other Docker containers) will see “localhost” that way.


(Jamiet) #3

Thank you for the reply @dmaze, very much appreciated.

You are correct about the machine’s IP:

$ docker-machine ip
192.168.99.100

Based on your advice I figured this was the correct avenue:

…if you need to access a container from outside, use -p to publish a port, then use the host system’s DNS name or IP address and the published port number.

So I interrogated my IP addresses:

>ipconfig
Windows IP Configuration
Ethernet adapter VirtualBox Host-Only Network:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::eccd:c897:60d3:1974%3
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet 2:
   Connection-specific DNS Suffix  . : redacted.co.uk
   Link-local IPv6 Address . . . . . : fe80::fdd6:fb55:8792:d57d%19
   IPv4 Address. . . . . . . . . . . : 10.193.17.7
   Subnet Mask . . . . . . . . . . . : 255.255.254.0
   Default Gateway . . . . . . . . . : 10.193.16.1

Ethernet adapter VirtualBox Host-Only Network #2:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::c875:b989:2dde:a83a%8
   IPv4 Address. . . . . . . . . . . : 192.168.99.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Wireless LAN adapter Wireless Network Connection:
   Connection-specific DNS Suffix  . : redacted.co.uk
   Link-local IPv6 Address . . . . . : fe80::d83:1c97:7617:4d62%11
   IPv4 Address. . . . . . . . . . . : 10.193.32.57
   Subnet Mask . . . . . . . . . . . : 255.255.248.0
   Default Gateway . . . . . . . . . : 10.193.32.1

and tried each one of those in docker run but none worked:

jamiet@XXX MINGW64 ~
$ docker run --rm -it -p 192.168.56.1:8889:8889  -v $(pwd):/notebook alexcoppe/pyspark
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint naughty_nobel (d454b11f76d7e2afab204e25660c1612ac7a3a8ed9f621ca09218d02a75e656c): Error starting userland proxy: listen tcp 192.168.56.1:8889: bind: cannot assign requested address.

jamiet@XXX MINGW64 ~
$ docker run --rm -it -p 10.193.17.7:8889:8889  -v $(pwd):/notebook alexcoppe/pyspark
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint kind_elion (5baad0205c9b66a55a271ddf6af4a995f2f022a3df7428afabfcce630b25877c): Error starting userland proxy: listen tcp 10.193.17.7:8889: bind: cannot assign requested address.

jamiet@XXX MINGW64 ~
$ docker run --rm -it -p 192.168.99.1:8889:8889  -v $(pwd):/notebook alexcoppe/pyspark
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint wonderful_shannon (807210a7bed16ea5112fdf38a3b95f570efc997ff6ed89125584e7b3260858c8): Error starting userland proxy: listen tcp 192.168.99.1:8889: bind: cannot assign requested address.

jamiet@XXX MINGW64 ~
$ docker run --rm -it -p 10.193.32.57:8889:8889  -v $(pwd):/notebook alexcoppe/pyspark
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint wizardly_shirley (23237b6912ebcd360f9d5239f64e3118c1199da939c1f736602f36877c84a0fc): Error starting userland proxy: listen tcp 10.193.32.57:8889: bind: cannot assign requested address.

So I’m still a little stumped I’m afraid. Not even sure what question to ask other than … help, why won’t it work?