-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
What docker images this feature is applicable to?
jupyter/base-notebook- Notebooks that use startup hooks to configure the environment
What changes do you propose?
Split start-notebook.sh or start.sh into a script that does the environment setup in an ENTRYPOINT, and a script that does the actual notebook startup in CMD.
Originally suggested in jupyterhub/zero-to-jupyterhub-k8s#2138 (comment)
How does this change will affect users?
start-notebook.sh calls start.sh which handles a lot of setup in the Jupyter environment, including:
- Running setup hooks such as for setting environment variables
docker-stacks/base-notebook/start.sh
Line 44 in 8dfdbfd
run-hooks /usr/local/bin/start-notebook.d - Customising user names and IDs when started as root
docker-stacks/base-notebook/start.sh
Lines 46 to 51 in 8dfdbfd
# If the container started as the root user, then we have permission to refit # the jovyan user, and ensure file permissions, grant sudo rights, and such # things before we run the command passed to start.sh as the desired user # (NB_USER). # if [ "$(id -u)" == 0 ] ; then
Since start-notebook.sh is set as the CMD if someone passes any arguments when running the Docker container all this setup is ignored. For example
docker run -e NB_UID=12345 -u 0 jupyter/base-notebook jupyter-lab --debug
should change the UID from the default 1000 to 12345, but since the startup scripts aren't run this leads to an error (can't be run as root). Instead you must run
docker run -e NB_UID=12345 -u 0 jupyter/base-notebook start.sh jupyter-lab --debug
A concrete example of where this is a problem for users is in the pyspark notebook- it isn't obvious to a user that the pyspark environment is setup by a startup script rather than being baked into the Dockerfile.
docker-stacks/pyspark-notebook/Dockerfile
Line 48 in 8dfdbfd
ln -s "${SPARK_HOME}/sbin/spark-config.sh" /usr/local/bin/before-notebook.d/spark-config.sh - https://discourse.jupyter.org/t/pyspark-library-is-missing-from-jupyter-pyspark-notebook-when-running-with-jupyterhub-zero-to-jupyterhub-k8s/8450
Note we're working around this in JupyterHub 2.0 and Z2JH 2.0 with a breaking change: jupyterhub/zero-to-jupyterhub-k8s#2449
Instead of specifying jupyterhub-singleuser as the CMD when running the image we'll use the image's default CMD, but I think this change is still generally helpful.