【问题标题】:Jupyter notebook URL's token gets truncated in Docker image on UbuntuJupyter 笔记本 URL 的令牌在 Ubuntu 上的 Docker 映像中被截断
【发布时间】:2018-05-05 23:30:27
【问题描述】:

我从 Anaconda 环境创建了一个 Docker 映像,一切顺利。但是,当我运行图像时,笔记本 URL 中带有令牌的部分被截断,因此我无法访问该链接。相反,它会提示我创建一个也需要令牌的密码(在网页上)。

这是我在全屏命令行模式下得到的输出。

我在跑步:

docker run crypto_forecaster

得到:

[I 23:23:47.302 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 23:23:47.732 NotebookApp] Serving notebooks from local directory: /usr/src/app
[I 23:23:47.732 NotebookApp] 0 active kernels
[I 23:23:47.732 NotebookApp] The Jupyter Notebook is running at:
[I 23:23:47.732 NotebookApp] http://0.0.0.0:8888/?token=...
[I 23:23:47.732 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

【问题讨论】:

  • 您可以使用 docker run -d -p 8888:8888 jupyter/scipy-notebook start-notebook.sh --NotebookApp.password='sha1:74ba40f8a388:c913541b7ee99d15d5ed31d4226bf7838f83a50e' 之类的东西定义自己的令牌。见:hub.docker.com/r/jupyter/scipy-notebook

标签: linux ubuntu docker command-line jupyter-notebook


【解决方案1】:

首先,您可以使用以下 python 代码生成哈希密码:

#!/usr/bin/env python3

from getpass import getpass
from hashlib import sha1

password = 'your-password'
m = sha1(password.encode('utf-8'))
print("SHA1: " + m.hexdigest())

然后将上面的 eMMe 添加到您的 docker run 命令中。如果您使用的是 docker compose,请将其添加到命令属性中:

   ...
   image: jupyter/scipy-notebook
   command: "start-notebook.sh --NotebookApp.password=$*your-sha1-password-above*"
   ports:
      - "8888:8888"
   ...

【讨论】:

    猜你喜欢
    • 2020-05-03
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    • 2021-12-10
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    相关资源
    最近更新 更多