简体   繁体   中英

Using Jupyter Lab with tmpnb

I am trying to use JupyterLab using tmpnb

I want to spawn many JupyterLab instances, just like the way tmpnb does for Jupyter Notebook.

I have created a new docker image by docker build -t jupyterlab2 . command using the following Dockerfile:

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

After this I am running the following commands:

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="*"'

When I visit the URL http://<ip-address>:8000 , I get redirected to http://<ip>:8000/user/sTVKGwH01uoQ , but this shows 404. I also tried visiting http://<ip>:8000/user/sTVKGwH01uoQ/lab but this too gives 404.

Logs for 1 instance are below:

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

I looked at an issue related to JupyterHub , which looked very similar. The 404 error page is same for me too. I tried some random things with start.sh too, but no luck.

Is it even possible to run JupyterLab using tmpnb? If no, then what are the other tools that I can use the achieve the same purpose?

The base URL must be set, otherwise the /user/... routes won't map to the right things. This is the --NotebookApp.base_url={base_path} part in the all of the example commands in the tmpnb README . These look like:

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

So a JupyterLab equivalent would be:

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

All of those apply with jupyterlab as well, so probably the only arg you want to replace is notebook with lab . At the same time, you don't need to change the default command at all, because if the lab extension is installed, jupyterlab is available at the /lab URL when you start jupyter notebook . You can see this right now by replacing /tree with /lab on any existing tmpnb.org URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM