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条回答
倾城 Initia
2楼-- · 2020-05-12 09:38

You can use the command jupyter notebook --allow-root --ip[of your container] or give access to all ip using option --ip0.0.0.0.

查看更多
迷人小祖宗
3楼-- · 2020-05-12 09:39

In the container you can run the following to make it available on your local machine (using your docker machine's ip address).

jupyter notebook --ip 0.0.0.0 --allow-root

You may not need to provide the --allow-root flag depending on your container's setup.

查看更多
爷、活的狠高调
4楼-- · 2020-05-12 09:41

Check out the Torus project that Manifold open sourced recently. We wanted an easy way for our ML engineers to hit the ground running on new projects with a consistent development environment across the entire team. This Python cookiecutter will scaffold out a new project structure for you that includes a Dockerfile that uses a pre-baked ML dev image that we put in Docker Hub and a Docker Compose config that takes care of all the port forwarding for you. The config is written to pick an open port on your host machine to forward to the notebook server running on 8888 inside the container. No more hassle running multiple notebook servers on your machine! Check it out hopefully this is helpful!

Github repo: https://github.com/manifoldai/docker-cookiecutter-data-science

Why we built it (w/ demo): https://medium.com/manifold-ai/torus-a-toolkit-for-docker-first-data-science-bddcb4c97b52

查看更多
该账号已被封号
5楼-- · 2020-05-12 09:45

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

Inside the Container : jupyter notebook --ip 0.0.0.0 --no-browser --allow-root

Host machine access this url : localhost:8888/tree‌​

When you are logging in for the first time there will be a link displayed on the terminal to log on with a token.

查看更多
再贱就再见
6楼-- · 2020-05-12 09:47

To get the link to your Jupyter notebook server:

After your docker run command, a hyperlink should be automatically generated. It looks something like this: http://localhost:8888/?token=f3a8354eb82c92f5a12399fe1835bf8f31275f917928c8d2 :: /home/jovyan/work

If you want to get the link again later down the line, you can type docker exec -it <docker_container_name> jupyter notebook list.

查看更多
beautiful°
7楼-- · 2020-05-12 09:48

You need to run your notebook on 0.0.0.0: jupyter notebook -i 0.0.0.0. Running on localhost make it available only from inside the container.

查看更多
登录 后发表回答