簡體   English   中英

無法在 docker(mac)中訪問 jupyter 筆記本

[英]Can't access jupyter notebook in docker (mac)

我想將 jupyter notebook 安裝到我的 docker 映像中。 在容器中安裝並運行后,我無法從瀏覽器訪問它。

這是我的最小設置:

Dockerfile:

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

集裝箱 output:

    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

我究竟做錯了什么?

默認情況下,Jupyter 配置為僅偵聽 localhost 接口,您需要將其配置為偵聽 0.0.0.0(容器的 localhost 不是您的主機 localhost..)

將 Dockerfile 中的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 = '*'
and change line starting with c.NotebookApp.ip to c.NotebookApp.ip = '0.0.0.0'

使用此問題尋求幫助: 為什么我無法訪問遠程 Jupyter Notebook 服務器?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM