Access Jupyter notebook running on Docker containe

2020-05-12 09:08发布

I created a docker image with python libraries and Jupyter. I start the container with the option -p 8888:8888, to link ports between host and container. When I launch a Jupyter kernel inside the container, it is running on localhost:8888 (and does not find a browser). I used the command jupyter notebook

But from my host, what is the IP address I have to use to work with Jupyter in host's browser ?

With the command ifconfig, I find eth0, docker, wlan0, lo ...

Thanks !

9条回答
你好瞎i
2楼-- · 2020-05-12 09:56

The below is how I get it running on Windows 7 with docker toolbox.

If you are using docker toolbox, open up the Docker quickstart terminal, and note the IP here:

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

Once you run the docker commands from the tensorflow installation website:

docker pull tensorflow/tensorflow                  # Download latest image
docker run -it -p 8888:8888 tensorflow/tensorflow  # Start a Jupyter notebook server

You will receive a message like this:

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://127.0.0.1:8888/?token=d6e80acaf08e09853dc72f6b0f022b8225f94f

In the host, replace 127.0.0.1 with 192.168.99.100 and use the rest of that URL

查看更多
看我几分像从前
3楼-- · 2020-05-12 09:59

The docker run command is mandatory to open a port for the container to allow the connection from a host browser, assigning the port to the docker container with -p, select your jupyter image from your docker images.

docker run -it -p 8888:8888 image:version

Inside the container launch the notebook assigning the port you opened:

jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --allow-root

Access the notebook through your desktops browser on http://localhost:8888 The notebook will prompt you for a token which was generated when you create the notebook.

查看更多
贪生不怕死
4楼-- · 2020-05-12 10:01

As an alternative to building your own Docker image, you can also use the ML Workspace image. The ML Workspace is an open-source web IDE that combines Jupyter, VS Code, a Desktop GUI, and many other tools & libraries into one convenient Docker image. Deploying a single workspace instance is as simple as:

docker run -p 8080:8080 mltooling/ml-workspace:latest

All tools are accessible from the same port and integrated into the Jupyter UI. You can find further documentation here.

查看更多
登录 后发表回答