I just managed to get streamlit working inside of JupyterHub.
Prereqs: Make sure to have https://github.com/jupyterhub/jupyter-server-proxy installed + enabled.
streamlit hello --browser.serverAddress 0.0.0.0 --server.enableCORS False
--server.port 8501 (in case you want to run it on a different port, like one opened in the container)
Running Jupyterhub with Docker, each user gets their own container with one of several pre-built environments they can choose from a drop-down list.
Issues I ran into:
- Finding documentation about command-line arguments was difficult. I didn’t have access to edit
~/.streamlit/config.tomlbecause of restricted access, hence the command-line.
serverproxyin a container that didn’t already have it pre-installed doesn’t seem to work. No explanation for why. Using an image that came with
serverproxywas fine. Intuition is that it shouldn’t matter, experiments have shown otherwise.
- CORS must be disabled. Stuck “loading” if not. I take care of all SSL at the
nginx-level, and proxy-pass to the jupyterhub instance, so the safety wasn’t a concern for me (hub is running on http). Let me know if I’m wrong (I’m not a web-dev).
- Had to visit
user/michael/proxy/5000/(and the trailing slash does matter)
- Technically, the user-image that worked for me used the following install instructions, not
git clone --depth 1 https://github.com/jupyterhub/jupyter-server-proxy && \ cd jupyter-server-proxy/jupyterlab-server-proxy && \ npm install && npm run build && jupyter labextension link . && \ npm run build && jupyter lab build
I ran that in a container that didn’t have the proxy installed, didn’t fix lack of access.
At PyDataLA right now, so I don’t quite have the time to dig in and build a minimally-working Dockerfile, but that’s definitely a next step for debugging.
A bloated image (with R/Julia/Octave/Python) that does allow the proxy-pass can be found on docker hub at