diff --git a/.env b/.env index b259374..a7ba0d9 100644 --- a/.env +++ b/.env @@ -17,6 +17,11 @@ DOCKER_NETWORK_NAME=jupyterhub-network # Single-user Jupyter Notebook server container image DOCKER_NOTEBOOK_IMAGE=jupyter/scipy-notebook:2d878db5cbff +# Notebook directory in the container. +# This will be /home/jovyan/work if the default +# This directory is stored as a docker volume for each user +DOCKER_NOTEBOOK_DIR=/home/jovyan/work + # Docker run command to use when spawning single-user containers DOCKER_SPAWN_CMD=start-singleuser.sh diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 982d843..026698a 100644 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -32,10 +32,11 @@ c.DockerSpawner.extra_start_kwargs = { 'network_mode': network_name } # it. Most jupyter/docker-stacks *-notebook images run the Notebook server as # user `jovyan`, and set the notebook directory to `/home/jovyan/work`. # We follow the same convention. -c.DockerSpawner.notebook_dir = '/home/jovyan/work' +notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work' +c.DockerSpawner.notebook_dir = notebook_dir # Mount the real user's Docker volume on the host to the notebook user's # notebook directory in the container -c.DockerSpawner.volumes = { '{username}': '/home/jovyan/work' } +c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir } c.DockerSpawner.extra_create_kwargs.update({ 'volume_driver': 'local' }) # Remove containers once they are stopped c.DockerSpawner.remove_containers = True