Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot access Lab directly (ignoring Spawner.default_url) #125

Closed
harapekoaomushi opened this issue Oct 31, 2016 · 11 comments
Closed

cannot access Lab directly (ignoring Spawner.default_url) #125

harapekoaomushi opened this issue Oct 31, 2016 · 11 comments

Comments

@harapekoaomushi
Copy link

I tried to test jupyterhub + dockerspawner with JupyterLab .

I can access Lab page if I type the URL (such that /user/%U/lab)
but I cannot access directly from Login Screen.

And I can access Lab directly when I don't use dockerspawner.

There are no logs to GET /lab or /user/%U/lab on the logs of jupyterhub and docker container.
I'm wondering if dockerspawner ignores or overwrites Spawner.default_url setting.

I use
jupyterhub 0.6.1 (installed by conda)
dockerspawner 0.5.0

The Dockerfile when I tried to build image is here.

FROM jupyterhub/singleuser:latest

USER root
RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y htop
RUN conda update --all -c defaults --yes
RUN conda config --set channel_priority false
RUN conda install -c conda-forge jupyterlab --yes
RUN jupyter serverextension enable --py jupyterlab --sys-prefix

And extract from my jupyterhub_config.py is here.

c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.hub_ip_connect = '172.17.0.1'
c.JupyterHub.hub_ip = '172.17.0.1'
c.DockerSpawner.container_image = "oooooooooo"
c.Spawner.default_url = '/lab'
@egorlitvinenko
Copy link

egorlitvinenko commented Nov 8, 2016

I think you need c.DockerSpawner.default_url = '/lab'

@steverweber
Copy link

perhaps helpful...

in docker logs while running in jupyterhub-singleuser --debug mode.

+ sudo -E -u s8weber jupyterhub-singleuser --debug --port=8888 --ip=0.0.0.0 --user=s8weber --cookie-name=jupyter-hub-token-s8weber --base-url=/user/s8weber --hub-prefix=/hub/ --hub-api-url=http://x.97.206.28:8081/hub/api
[D 2016-11-08 14:23:37.149 s8weber application:178] Searching ['/u/s8weber', '/u/s8weber/.jupyter', '/usr/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 2016-11-08 14:23:37.150 s8weber application:555] Looking for jupyter_config in /etc/jupyter
[D 2016-11-08 14:23:37.151 s8weber application:555] Looking for jupyter_config in /usr/local/etc/jupyter
[D 2016-11-08 14:23:37.152 s8weber application:555] Looking for jupyter_config in /usr/etc/jupyter
[D 2016-11-08 14:23:37.152 s8weber application:555] Looking for jupyter_config in /u/s8weber/.jupyter
[D 2016-11-08 14:23:37.155 s8weber application:555] Looking for jupyter_config in /u/s8weber
[D 2016-11-08 14:23:37.158 s8weber application:555] Looking for jupyter_notebook_config in /etc/jupyter
[D 2016-11-08 14:23:37.159 s8weber application:555] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
[D 2016-11-08 14:23:37.159 s8weber application:555] Looking for jupyter_notebook_config in /usr/etc/jupyter
**** [D 2016-11-08 14:23:37.160 s8weber application:577] Loaded config file: /usr/etc/jupyter/jupyter_notebook_config.json
[D 2016-11-08 14:23:37.160 s8weber application:555] Looking for jupyter_notebook_config in /u/s8weber/.jupyter
** this might be bad... user config might not have ext for lab.
**** [D 2016-11-08 14:23:37.165 s8weber application:577] Loaded config file: /u/s8weber/.jupyter/jupyter_notebook_config.json
[D 2016-11-08 14:23:37.165 s8weber application:555] Looking for jupyter_notebook_config in /u/s8weber

found that local users config was loaded.
so I had to remove it.

rm -rf /u/s8weber/.jupyter

now /lab works for me.

@harapekoaomushi
Copy link
Author

@egorlitvinenko
Thank you for your advice. I tried it but it is not valid unfortunately.
On DockerSpawner class of dockerspawner.py, there are no variable named "default_url"
I may try to change other variable on DockerSpawner class.
Thanks.

@harapekoaomushi
Copy link
Author

@steverweber

Thank you for your advice and test on your environment.

I tried to delete /home/jovyan/.jupyter directory on the container
and to add debug option into /srv/singleuser/singleuser.sh

Then I stopped this container and started it by jupyterhub.

But /lab does not load directly from login screen.

(I can use lab when I manually type lab's URL.)

My logs on this container (debug mode, after delete /home/jovyan/.jupyter) is here.

[D 2016-11-09 05:17:59.981 user001 application:178] Searching ['/home/jovyan/work', '/home/jovyan/.jupyter', '/opt/conda/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 2016-11-09 05:17:59.982 user001 application:555] Looking for jupyter_config in /etc/jupyter
[D 2016-11-09 05:17:59.982 user001 application:555] Looking for jupyter_config in /usr/local/etc/jupyter
[D 2016-11-09 05:17:59.983 user001 application:555] Looking for jupyter_config in /opt/conda/etc/jupyter
[D 2016-11-09 05:17:59.983 user001 application:555] Looking for jupyter_config in /home/jovyan/.jupyter
[D 2016-11-09 05:17:59.983 user001 application:555] Looking for jupyter_config in /home/jovyan/work
[D 2016-11-09 05:17:59.985 user001 application:555] Looking for jupyter_notebook_config in /etc/jupyter
[D 2016-11-09 05:17:59.985 user001 application:555] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
[D 2016-11-09 05:17:59.985 user001 application:555] Looking for jupyter_notebook_config in /opt/conda/etc/jupyter
[D 2016-11-09 05:17:59.986 user001 application:577] Loaded config file: /opt/conda/etc/jupyter/jupyter_notebook_config.json
[D 2016-11-09 05:17:59.986 user001 application:555] Looking for jupyter_notebook_config in /home/jovyan/.jupyter
[D 2016-11-09 05:17:59.987 user001 application:555] Looking for jupyter_notebook_config in /home/jovyan/work
[D 2016-11-09 05:17:59.993 user001 manager:45] [nb_conda_kernels] refreshing conda info
[D 2016-11-09 05:18:00.785 user001 manager:145] [nb_conda_kernels] refreshing conda kernelspecs
[I 2016-11-09 05:18:00.786 user001 manager:32] [nb_conda_kernels] enabled, 3 kernels found
[I 2016-11-09 05:18:00.906 user001 __init__:35] ✓ nbpresent HTML export ENABLED
[W 2016-11-09 05:18:00.906 user001 __init__:43] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 2016-11-09 05:18:00.909 user001 __init__:149] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.5/site-packages/jupyterlab
[I 2016-11-09 05:18:01.030 user001 handlers:73] [nb_anacondacloud] enabled
[I 2016-11-09 05:18:01.036 user001 handlers:290] [nb_conda] enabled
[I 2016-11-09 05:18:01.039 user001 notebookapp:1128] Serving notebooks from local directory: /home/jovyan/work
[I 2016-11-09 05:18:01.040 user001 notebookapp:1128] 0 active kernels 
[I 2016-11-09 05:18:01.040 user001 notebookapp:1128] The Jupyter Notebook is running at: http://0.0.0.0:8888/user/user001/
[I 2016-11-09 05:18:01.040 user001 notebookapp:1129] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 2016-11-09 05:18:01.046 user001 log:47] 302 GET /user/user001 (172.17.0.1) 5.06ms
[I 2016-11-09 05:18:01.478 user001 log:47] 302 GET /user/user001 (172.17.0.1) 0.48ms
[D 2016-11-09 05:18:01.605 user001 handlers:178] Using contents: services/contents
[D 2016-11-09 05:18:01.657 user001 log:47] 200 GET /user/user001/tree (172.17.0.1) 67.75ms
[D 2016-11-09 05:18:01.882 user001 log:47] 304 GET /user/user001/custom/custom.css (172.17.0.1) 1.54ms
[D 2016-11-09 05:18:02.182 user001 log:47] 200 GET /user/user001/static/services/contents.js?v=20161109051800 (172.17.0.1) 1.97ms
[D 2016-11-09 05:18:02.190 user001 log:47] 200 GET /user/user001/custom/custom.js?v=20161109051800 (172.17.0.1) 1.61ms
[D 2016-11-09 05:18:02.305 user001 log:47] 200 GET /user/user001/api/config/tree?_=1478668682053 (172.17.0.1) 3.62ms
[D 2016-11-09 05:18:02.311 user001 log:47] 200 GET /user/user001/api/config/common?_=1478668682054 (172.17.0.1) 2.24ms
[D 2016-11-09 05:18:02.321 user001 log:47] 200 GET /user/user001/api/terminals?_=1478668682055 (172.17.0.1) 0.76ms
[D 2016-11-09 05:18:02.330 user001 log:47] 200 GET /user/user001/api/terminals?_=1478668682057 (172.17.0.1) 0.74ms
[D 2016-11-09 05:18:02.332 user001 log:47] 200 GET /user/user001/api/sessions?_=1478668682056 (172.17.0.1) 1.16ms
[D 2016-11-09 05:18:02.362 user001 kernelspec:132] Found kernel python2 in /usr/local/share/jupyter/kernels
[D 2016-11-09 05:18:02.366 user001 kernelspec:139] Native kernel (python3) available from /opt/conda/lib/python3.5/site-packages/ipykernel/resources
[D 2016-11-09 05:18:02.367 user001 kernelspec:132] Found kernel python2 in /usr/local/share/jupyter/kernels
[D 2016-11-09 05:18:02.367 user001 kernelspec:139] Native kernel (python3) available from /opt/conda/lib/python3.5/site-packages/ipykernel/resources
[D 2016-11-09 05:18:02.369 user001 log:47] 200 GET /user/user001/api/kernelspecs (172.17.0.1) 8.80ms
[D 2016-11-09 05:18:02.742 user001 log:47] 200 GET /user/user001/api/contents?type=directory&_=1478668682058 (172.17.0.1) 1.43ms
[D 2016-11-09 05:18:02.751 user001 log:47] 200 GET /user/user001/nbextensions/nb_conda/tree.js?v=20161109051800 (172.17.0.1) 1.77ms
[D 2016-11-09 05:18:02.862 user001 log:47] 200 GET /user/user001/nbextensions/nb_conda/models.js?v=20161109051800 (172.17.0.1) 2.07ms
[D 2016-11-09 05:18:02.871 user001 log:47] 200 GET /user/user001/nbextensions/nb_conda/urls.js?v=20161109051800 (172.17.0.1) 1.55ms
[D 2016-11-09 05:18:02.873 user001 log:47] 200 GET /user/user001/nbextensions/nb_conda/views.js?v=20161109051800 (172.17.0.1) 1.77ms
[D 2016-11-09 05:18:02.972 user001 log:47] 200 GET /user/user001/nbextensions/nb_conda/common.js?v=20161109051800 (172.17.0.1) 1.89ms
[D 2016-11-09 05:18:03.182 user001 log:47] 304 GET /user/user001/nbextensions/nb_conda/conda.css (172.17.0.1) 1.16ms
[D 2016-11-09 05:18:03.190 user001 log:47] 304 GET /user/user001/nbextensions/nb_conda/tab.html (172.17.0.1) 0.98ms

@steverweber
Copy link

perhaps use

    --SingleUserNotebookApp.default_url=/lab \

like.
sudo -E -u $USER jupyterhub-singleuser \
    --debug \
    --port=8888 \
    --ip=0.0.0.0 \
    --user=$JPY_USER \
    --cookie-name=$JPY_COOKIE_NAME \
    --base-url=$JPY_BASE_URL \
    --hub-prefix=$JPY_HUB_PREFIX \
    --hub-api-url=$JPY_HUB_API_URL \
    --SingleUserNotebookApp.default_url=/lab \
    --SingleUserNotebookApp.disable_user_config=True \
...

@harapekoaomushi
Copy link
Author

@steverweber
Great!!
I can access /lab directly when the following parameters are set on Dockerfile equal to your recommended arguments.
Thank you very much.

CMD ["sh", "/srv/singleuser/singleuser.sh", "--SingleUserNotebookApp.default_url=/lab", "--SingleUserNotebookApp.disable_user_config=True"]

@Analect
Copy link

Analect commented Nov 16, 2016

@harapekoaomushi
I'm having real trouble getting jupyterhub up and running with jupyterlab ... is there any chance you might be able to put your working version up on a public github repo somewhere so I can try to get all the moving parts working? Thanks.

@harapekoaomushi
Copy link
Author

@Analect
Here you are.
https://github.com/harapekoaomushi/jupyterLabHubDockerspawnerSample

Now I checked this configuration can work.

Good luck !

@Analect
Copy link

Analect commented Nov 16, 2016

Thanks @harapekoaomushi . I'll try this. Have been trying to get the multi-user dockerized version (with user folders backed-up to docker volumes) working against the latest jupyterhub server release over here.

@KimBenjaminTang
Copy link

KimBenjaminTang commented Apr 19, 2023

For anyone working with jupyter notebook images in Docker, for example "jupyter/base-notebook" etc., you can modify the defaultUrl by specifiying the argument in the Dockerfile:

For example:

FROM jupyter/base-notebook:python-3.8.5
ARG JUPYTERHUB_VERSION
USER root

RUN pip3 install --no-cache jupyterhub==$JUPYTERHUB_VERSION

COPY ./jupyterhub/requirements.txt .

RUN python3 -m pip install -r requirements.txt

ENV NOTEBOOK_ARGS="--SingleUserNotebookApp.default_url=/lab"

USER ${NB_UID}

As @harapekoaomushi pointed out, setting c.DockerSpawner.default_url = '/lab' does not work, so this is a workaround to fix that.

@gregjan
Copy link

gregjan commented Jul 27, 2023

Thank you @KimBenjaminTang. Is there a way to set this at runtime via the spawner? I need to add a username variable to that path..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants