k0tbert
k0tbert

Reputation: 1

Problem accessing jupyter notebook from Docker Toolbox Container

I just set up a Docker Container with the Docker Toolbox and ran jupyter notebook inside the container using

docker run --name container -v %somedirectory%:%someotherdir% -d -p 127.0.0.1:8888:8888 quay.io/fenicsproject/stable:2017.2.0 'jupyter-notebook --ip=0.0.0.0'

Afterwards I can check the log of the container to see the URL and token that jupyter notebook created.

If I now go ahead and copy the link to my browser, it won't be able to connect to localhost. Accessing 127.0.0.1 does not work either.

Since the Docker Toolbox relies on Virtual Box VMs, I also tried to use the IP address of the VM, in this case 192.168.99.100:2376. According to the Kitematic UI, this is the IP:Port combination that is being published by the docker-machine and indeed this does not lead to a generic connection error. Instead the browser's output is:

Client sent an HTTP request to an HTTPS server.

I don't really know what to do from this point on. What does this "error" mean? Does it even make sense to use the VM's IP address? And most importlanty: what else can I do in order to finally get access to the jupyter notebook?

PS: I also tried the suggestions made in the threads Can't access jupyter notebook from docker and Access Jupyter notebook running on Docker container and couldn't make any of them work unfortunately.

I hope someone can help, thank you very much in advance.

Upvotes: 0

Views: 325

Answers (1)

David Maze
David Maze

Reputation: 160013

You need to do two things to make this work:

  1. Remove the 127.0.0.1 part of the port mapping; docker run -p 8888:8888 ...
  2. Connect to the docker-machine ip address with the published port; http://192.168.99.100:8888.

Docker Toolbox runs Docker in a separate Linux virtual machine. Any docker run -p options will get interpreted from the point of view of that VM. If you docker run -p 127.0.0.1:... then the published port will be bound to the VM's lo0 localhost interface, so it won't be reachable from outside the VM.

Once you have the port published, you need to connect to that specific port. Port 2376 is typically the port to reach the Docker daemon inside the VM, with mutual TLS security; you only need this for manual docker commands. To reach services running inside the VM you need to connect to the published port (the first number in the docker run -p option).

Upvotes: 1

Related Questions