diff --git a/base-notebook/Dockerfile b/base-notebook/Dockerfile index 998cf0bf..cb533246 100644 --- a/base-notebook/Dockerfile +++ b/base-notebook/Dockerfile @@ -24,6 +24,7 @@ RUN apt-get update && apt-get -yq dist-upgrade \ sudo \ locales \ fonts-liberation \ + run-one \ && rm -rf /var/lib/apt/lists/* RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ diff --git a/base-notebook/start-notebook.sh b/base-notebook/start-notebook.sh index b38c738d..ed6d0665 100755 --- a/base-notebook/start-notebook.sh +++ b/base-notebook/start-notebook.sh @@ -4,11 +4,16 @@ set -e +wrapper="" +if [[ "${RESTARTABLE}" == "yes" ]]; then + wrapper="run-one-constantly" +fi + if [[ ! -z "${JUPYTERHUB_API_TOKEN}" ]]; then # launched by JupyterHub, use single-user entrypoint exec /usr/local/bin/start-singleuser.sh "$@" elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then - . /usr/local/bin/start.sh jupyter lab "$@" + . /usr/local/bin/start.sh $wrapper jupyter lab "$@" else - . /usr/local/bin/start.sh jupyter notebook "$@" + . /usr/local/bin/start.sh $wrapper jupyter notebook "$@" fi diff --git a/docs/using/common.md b/docs/using/common.md index 5e10bc17..5290b148 100644 --- a/docs/using/common.md +++ b/docs/using/common.md @@ -33,6 +33,7 @@ the notebook server. You do so by passing arguments to the `docker run` command. * `-e GRANT_SUDO=yes` - Instructs the startup script to grant the `NB_USER` user passwordless `sudo` capability. You do **not** need this option to allow the user to `conda` or `pip` install additional packages. This option is useful, however, when you wish to give `$NB_USER` the ability to install OS packages with `apt` or modify other root-owned files in the container. For this option to take effect, you must run the container with `--user root`. (The `start-notebook.sh` script will `su $NB_USER` after adding `$NB_USER` to sudoers.) **You should only enable `sudo` if you trust the user or if the container is running on an isolated host.** * `-e GEN_CERT=yes` - Instructs the startup script to generates a self-signed SSL certificate and configure Jupyter Notebook to use it to accept encrypted HTTPS connections. * `-e JUPYTER_ENABLE_LAB=yes` - Instructs the startup script to run `jupyter lab` instead of the default `jupyter notebook` command. Useful in container orchestration environments where setting environment variables is easier than change command line parameters. +* `-e RESTARTABLE=yes` - Runs Jupyter in a loop so that quitting Jupyter does not cause the container to exit. This may be useful when you need to install extensions that require restarting Jupyter. * `-v /some/host/folder/for/work:/home/jovyan/work` - Mounts a host machine directory as folder in the container. Useful when you want to preserve notebooks and other work even after the container is destroyed. **You must grant the within-container notebook user or group (`NB_UID` or `NB_GID`) write access to the host directory (e.g., `sudo chown 1000 /some/host/folder/for/work`).** * `--user 5000 --group-add users` - Launches the container with a specific user ID and adds that user to the `users` group so that it can modify files in the default home directory and `/opt/conda`. You can use these arguments as alternatives to setting `$NB_UID` and `$NB_GID`.