0

我正在尝试使用JupyterLab使用tmpnb

我想生成许多JupyterLab实例,就像tmpnb为 Jupyter Notebook 所做的那样。

docker build -t jupyterlab2 .使用以下 Dockerfile 通过命令创建了一个新的 docker 映像:

FROM jupyter/datascience-notebook
MAINTAINER apr
RUN pip install npm
RUN pip install jupyterlab
RUN jupyter serverextension enable --py jupyterlab

在此之后,我正在运行以下命令:

export TOKEN=$( head -c 30 /dev/urandom | xxd -p )

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=tmpnb -v /var/run/docker.sock:/docker.sock jupyter/tmpnb python orchestrate.py --allow_origin='*' --image='jupyterlab2' --pool-size=5 --container-user=root  --command='jupyter lab --allow-root LabApp.allow_origin="*"'

当我访问 URLhttp://<ip-address>:8000时,我被重定向到http://<ip>:8000/user/sTVKGwH01uoQ,但这显示 404。我也尝试访问http://<ip>:8000/user/sTVKGwH01uoQ/lab,但这也给出了 404。

1 个实例的日志如下:

Set username to: jovyan
usermod: no changes
Set jovyan GID to: 100
Execute the command: jupyter lab --allow-root --port 8888 --ip=0.0.0.0 --LabApp.allow_origin=*
[I 09:05:52.598 LabApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 09:05:54.689 LabApp] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
[I 09:05:54.694 LabApp] Serving notebooks from local directory: /home/jovyan
[I 09:05:54.694 LabApp] 0 active kernels
[I 09:05:54.694 LabApp] The Jupyter Notebook is running at:
[I 09:05:54.694 LabApp] http://0.0.0.0:8888/?token=584fc5114d037ad23296ca8284ea1074b220d058018cb2c4
[I 09:05:54.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:05:54.695 LabApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://0.0.0.0:8888/?token=584fc5114d037ad23296ca8284ea1074b220d058018cb2c4
[I 09:05:57.142 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.54ms
[W 09:05:57.144 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.45ms referer=None
[I 09:05:57.347 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:57.350 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.44ms referer=None
[I 09:05:57.553 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.55ms
[W 09:05:57.556 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.41ms referer=None
[I 09:05:57.767 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 2.80ms
[W 09:05:57.773 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 3.44ms referer=None
[I 09:05:57.978 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:57.981 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.46ms referer=None
[I 09:05:58.184 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.55ms
[W 09:05:58.187 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.42ms referer=None
[I 09:05:58.391 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:58.394 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 2.05ms referer=None
[W 09:06:18.518 LabApp] 404 GET /user/1BhE9UZ2gg5o/tree (172.17.0.1) 1.61ms referer=http://52.71.15.52:8000/
[W 09:06:27.502 LabApp] 404 GET /user/1BhE9UZ2gg5o/lab (172.17.0.1) 2.51ms referer=None
[W 09:07:20.568 LabApp] 404 GET /user/1BhE9UZ2gg5o/lab (172.17.0.1) 2.28ms referer=None

我查看了一个与 JupyterHub 相关的问题,看起来非常相似。404错误页面对我来说也是一样的。我也尝试了一些随机的东西start.sh,但没有运气。

甚至可以使用 tmpnb 运行 JupyterLab 吗?如果不是,那么我可以使用哪些其他工具来达到相同的目的?

4

1 回答 1

0

必须设置基本 URL,否则/user/...路由不会映射到正确的东西。这是tmpnb README--NotebookApp.base_url={base_path}中所有示例命令的一部分。这些看起来像:

python orchestrate.py --command='jupyter notebook --no-browser \
    --port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} \
    --NotebookApp.port_retries=0'

所以一个 JupyterLab 等价物是:

python orchestrate.py --command='jupyter lab --no-browser \
    --port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} \
    --NotebookApp.port_retries=0'

所有这些也适用于 jupyterlab,因此您想要替换的唯一 arg 可能是notebookwith lab。同时,您根本不需要更改默认命令,因为如果安装了实验室扩展,则 jupyterlab/lab在您启动时的 URL处可用jupyter notebook。您现在可以通过替换任何现有的 tmpnb.org URL 来看到这/tree一点/lab

于 2017-12-07T12:24:24.210 回答