Skip to content

Commit ac7df72

Browse files
authored
Merge pull request #917 from jeffyjefflabs/restartable
Option to enable restart without exiting container
2 parents 307ad2b + a667552 commit ac7df72

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

base-notebook/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ RUN apt-get update && apt-get -yq dist-upgrade \
2424
sudo \
2525
locales \
2626
fonts-liberation \
27+
run-one \
2728
&& rm -rf /var/lib/apt/lists/*
2829

2930
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \

base-notebook/start-notebook.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44

55
set -e
66

7+
wrapper=""
8+
if [[ "${RESTARTABLE}" == "yes" ]]; then
9+
wrapper="run-one-constantly"
10+
fi
11+
712
if [[ ! -z "${JUPYTERHUB_API_TOKEN}" ]]; then
813
# launched by JupyterHub, use single-user entrypoint
914
exec /usr/local/bin/start-singleuser.sh "$@"
1015
elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then
11-
. /usr/local/bin/start.sh jupyter lab "$@"
16+
. /usr/local/bin/start.sh $wrapper jupyter lab "$@"
1217
else
13-
. /usr/local/bin/start.sh jupyter notebook "$@"
18+
. /usr/local/bin/start.sh $wrapper jupyter notebook "$@"
1419
fi

docs/using/common.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ the notebook server. You do so by passing arguments to the `docker run` command.
3333
* `-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.**
3434
* `-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.
3535
* `-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.
36+
* `-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.
3637
* `-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`).**
3738
* `--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`.
3839

0 commit comments

Comments
 (0)