JupyterHub + Panel

I have a Docker Image with a LDAP authenticated JupyterHub that spawns a JupyterLab instance remotely. I am trying to use app.show( port=8012 , websocket_origin="arkham" , threaded=True ) where arkham is the name of the machine hosting. I currently use docker run -p 8011:8000 -p 8012:8001 -v /home/cmss/USE/R/:/home/USER/ testhub hoping that when I run my .show( ... ) line it would be available because I expose the 8012 port to 8001. I get blocked and am curious to know why? Has anyone managed to get such a setup working?

Hi @StuckDuckF

I use another solution which I believe is better. The solution is the jupyter-server-proxy. With that installed each user can start web servers including the Panel/ Bokeh web server at arbitrary ports and access the applications in their browser.

In my jupyterhub i can run panel serve hello_world.ipynb in a terminal and it shows up at .../user/<my-user-name>/proxy/5006/hello_world.

You should be able to use --port to set the port you want. You should also be able to use .show inside your notebook or script and it works similarly.

If you want to “install” Panel applications on your jupyter hub, you can do that via the jupyter-panel-proxy. Then you will get an icon you can click in the Jupyter Hub launcher for each Panel application.

The jupyter-server-proxy and the jupyter-panel-proxy is installed when you launch panel 0.13.1 on binder. We also run the code-server there :slight_smile: Try it out.


You can see how panel binder is configured here.

The combination of JupyterHub and Panel is awesome.


Is jupter-server-proxy Docker compatible? I am trying to allow for users have access to their homes on a network and currentl;y I have a working JupyterHub that spawns JupterLab that works as intended but I am not sure how to configure my Dockerfile to use jupter-server-proxy to solve my problem. Is there an example I can follow (if not I will document how I solve this and put it on the docs)?

PS The binder apps spaner does not work as it throws a lot of errors pertaining css
GET https://notebooks.gesis.org/binder/jupyter/user/holoviz-panel-ynnhp8ei/panel/components/panel.template.fast.list/FastListTemplate/css/fast_bokeh_slickgrid.css net::ERR_ABORTED 404 CanvasDraw:67 GET https://notebooks.gesis.o

1 Like

The jupyter-server-proxy is a python package. You should not need to do more than pip install or conda install it together with the other python packages you install in your base python environment.

As you can see it takes the port issues out of the equation. It just makes apps running inside the docker container available on the same port as everything else but at specific url with a proxy/<port>/... postfix.

1 Like

Great I am trying right now but keep getting an error about where my files are. Any tips on how to make sure that the files in the same directory as the notebooks are available for loading using xarray? I am currently reading up on Static Directories option in panel serve.

1 Like

Try to make the question more specific with a minimal, reproducible example. Thanks.

1 Like

I have a directory with the following structure :

  • Dockerfile (I am open to a simpler Dockerfile but this is what I have “working” so far)
FROM ubuntu:bionic
RUN apt-get update && \
    apt-get install -y apt-utils wget && \
    apt-get clean -y

RUN mkdir -p /opt/conda && \
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/conda/miniconda.sh && \
    bash /opt/conda/miniconda.sh -b -u -p /opt/conda

ENV PATH=$PATH:/opt/conda/condabin:/opt/conda/bin
COPY environment.yml /environment.yml
COPY requirements.txt /requirements.txt
RUN . activate
RUN conda install -y -c conda-forge mamba
RUN mamba install -y -c conda-forge --file /environment.yml
RUN python -m pip install --upgrade pip
RUN python -m pip install -r /requirements.txt
RUN conda clean -a -y
COPY entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]
  • entrypoiny.sh

panel serve --autoreload --address --port 8000 --allow-websocket-origin="*" --static-dirs apps=./usr/src/app/apps/  /usr/src/app/apps/*.ipynb

tail -f /dev/null
  • requirements.txt : pip specific packages to install for the environment
  • environment.yml : conda-forge compatible packages that mamba installs

and I run it with

docker run -p 8066:8000 -v /PATH_TO_NOTEBOOKS/apps:/usr/src/app/apps yp2

My problem is I see the multi app page but when I click on App 1 I get no errors but the app only partially renders. I tried changing the file_list in the notebook because I kept getting an error to try and match the structure of the panel server.

1 Like

If there is no error in the server logs then they might be in the browser console logs.

Are there any errors in the browser console logs? How to Open the Browser Console on Chrome, Safari, Firefox, and Edge - Appuals.com

Part of the problem is I do not get any meaningful errors. As you can see the browser console is clear and the terminal log simply shows some warnings but no error.

Here is a Google Drive Folder of the entire app (including static files) which you can build and run using Docker.
docker run -p 8066:8000 -v /PATH_TO_APPS/apps:/usr/src/app/apps yp2