我正在尝试使用JupyterLab
来tmpnb我想生成许多JupyterLab个实例,就像{Jupyter Notebook} tmpnb的方式一样。
我使用以下Dockerfile通过docker build -t jupyterlab2 .
命令创建了一个新的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="*"'
当我访问网址http://<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
我看了an issue related to JupyterHub,看起来非常相似。 404错误页面对我来说也是一样的。我用start.sh
尝试了一些随机的东西,但没有运气。
甚至可以使用tmpnb运行JupyterLab吗?如果不是,那么我可以使用的其他工具有哪些实现相同的目的?
答案 0 :(得分:0)
必须设置基本URL,否则/user/...
路由将不会映射到正确的内容。这是所有示例命令in the 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可能是notebook
和lab
。同时,您根本不需要更改默认命令,因为如果安装了实验室扩展,则在您启动/lab
时,jupyter notebook
URL会显示jupyterlab。您现在可以通过在任何现有tmpnb.org网址上将/tree
替换为/lab
来查看此内容。