【问题标题】:In Jupyter docker , cannot connect to kernel在 Jupyter docker 中,无法连接到内核
【发布时间】:2020-09-20 14:32:18
【问题描述】:

在安装 Jupyter docker 时,例如这个:

docker run -d \
    --hostname jupyterhub-ds \
    --log-opt max-size=50m \
    -p 8000:8000 \
    -p 5006:5006 \
    -e DOCKER_USER=$(id -un) \
    -e DOCKER_USER_ID=$(id -u) \
    -e DOCKER_PASSWORD=$(id -un) \
    -e DOCKER_GROUP_ID=$(id -g) \
    -e DOCKER_ADMIN_USER=$(id -un) \
    -v "$(pwd)":/workdir \
    -v "$(dirname $HOME)":/home_host \
    dclong/jupyterhub-ds /scripts/sys/init.sh

JupyterLab 启动良好,我进入实验室。通过 URL+端口。 但是,这无法连接到内部python内核(连接挂起)。

我面临什么样的安全? 这与套接字通信安全有关吗?

调查后,我收到了这些消息:

[D 16:01:39.488 NotebookApp] Starting kernel: ['/usr/local/bin/python', '-m', 'ipykernel_launcher', '-f', '/root/.local/share/jupyter/runtime/kernel-f0420fbf-12e918f-20df7d3e804a.json']
[D 16:01:39.491 NotebookApp] Connecting to: tcp://127.0.0.1:51775
[D 16:01:39.491 NotebookApp] Connecting to: tcp://127.0.0.1:38609
[I 16:01:39.492 NotebookApp] Kernel started: f0420fbf-12ef-403e-918f-20df7d3e804a
[D 16:01:39.492 NotebookApp] Kernel args: {'kernel_name': 'python3', 'cwd': '/'}
[D 16:01:39.493 NotebookApp] Clearing buffer for 5e93046f-aa3e-4edd-a018-66b9d4c752e5
[I 16:01:39.493 NotebookApp] Kernel shutdown: 5e93046f-aa3e-4edd-a018-66b9d4c752e5

它似乎与这个有关: https://jupyter-notebook.readthedocs.io/en/stable/public_server.html

        Firewall Setup
        To function correctly, the firewall on the computer running the jupyter notebook server must be configured to allow connections from client machines
     on the access port c.NotebookApp.port set in jupyter_notebook_config.py to allow connections to the web interface. 

    The firewall must also allow connections from 127.0.0.1 (localhost) on ports from 49152 to 65535. These ports are used by the server to communicate with the notebook kernels. 

The kernel communication ports are chosen randomly by ZeroMQ, 

每个内核可能需要多个连接,因此必须可以访问大范围的端口。

【问题讨论】:

标签: docker jupyter firewall jupyter-lab websecurity


【解决方案1】:

我不确定您是如何构建 docker 命令的,或者您为什么选择特定的 Docker 映像 dclong/jupyterhub?

如果它是为运行 jupyterhub(多用户)而设计的,那么如果您尝试在 docker 中运行自己的 Jupyter 服务器,它听起来并不像您需要的那样,只是为您服务。

我建议使用 jupyter/scipy-notebook 之类的东西,而不是专门为运行一个 Jupyter 服务器而设计的。

否则,请描述您真正想要运行的内容,或者您​​认为需要使用该图像的原因等。

【讨论】:

  • 这与 websocket 被安全阻止有关
猜你喜欢
  • 2019-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多