无法在Docker中访问jupyter笔记本

lf3rwulv  于 2023-01-16  发布在  Docker
关注(0)|答案(1)|浏览(387)

我想把jupyter notebook安装到我的docker镜像中,安装并在container中运行后,我无法从浏览器访问它。
下面是我的最小设置:
停靠文件:

FROM python:3.7.5
RUN pip install jupyterlab
EXPOSE 8888
CMD jupyter-lab --allow-root

命令

docker build -t my_image .
docker run -p 8888:8888 my_image

集装箱产量:

To access the server, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/jpserver-7-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=e6b9a5dd573aabc52e6753e7b21f0daf6270e685055afa50
     or http://127.0.0.1:8888/lab?token=e6b9a5dd573aabc52e6753e7b21f0daf6270e685055afa50

我尝试打开这些链接中的任何一个,并在浏览器中收到此消息:

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE

我哪里做错了?

3pmvbmvn

3pmvbmvn1#

默认情况下Jupyter配置为只监听localhost接口,您需要将其配置为监听0.0.0.0(容器的localhost不是您的主机localhost..)
将停靠文件中的CMD行更改为CMD jupyter-lab notebook --ip 0.0.0.0 --port 8888 --allow-root
或编辑容器/图像中的jupyter_notebook_config.py
将以c.NotebookApp.allow_origin开头的行更改为c.NotebookApp.allow_origin = '*'
并将以c.NotebookApp.ip开头的行更改为c.NotebookApp.ip = '0.0.0.0'
使用此问题寻求帮助:Why I can't access remote Jupyter Notebook server?

相关问题