Hi folks ,
So my usecase is that I am a teacher And I have hosted a jupyterhub on an ubuntu server so that my students can work on datascience projects. I am attaching volumes so that each user/student has different workspace. Now I want to pre install/download/attach some notebooks in my students workspace or attached a common read only volume for all containers (so that students can duplicate it and work on it) How do I do this here ?
I tried shared_volumes but I was not able to see those notebooks.
I would love to see something like this
host/path/to/notebooks/<all_notebooks.ipynb> binds-to /home/jovyn/work/sample-notebooks
My JupyterHub config file:
import dockerspawner
import os
#from IPython.utils.localinterfaces import public_ips
from jupyter_client.localinterfaces import public_ips
import subprocess
c = get_config() # noqa
c.Authenticator.admin_users = {'ross'}
c.DockerSpawner.allowed_images = {
'Python Base Notebook': 'quay.io/jupyter/base-notebook:latest',
'Python Scipy Notebook': 'quay.io/jupyter/scipy-notebook:latest'
}
c.JupyterHub.spawner_class = dockerspawner.DockerSpawner
c.JupyterHub.hub_ip = public_ips()[0]
def create_dir_hook(spawner):
username = spawner.user.name
volume_path = os.path.join('/home', username)
volume_path = os.path.join(volume_path, 'jupyterhub_volume_data')
print(volume_path)
if not os.path.exists(volume_path):
print("Path doesnt exist")
os.makedirs(volume_path)
c.Spawner.pre_spawn_hook = create_dir_hook
notebook_dir = '/home/jovyan/work'
host_dir = '/home/{username}/jupyterhub_volume_data/'
print(notebook_dir)
print(host_dir)
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 = {
f'{host_dir}': notebook_dir
}
c.DockerSpawner.remove = True
c.DockerSpawner.extra_create_kwargs = {'user': 'root'}
# c.DockerSpawner.extra_host_config = {'runtime': 'nvidia'}
#https://hackmd.io/@DanielChen/Sy81P-Aw4?type=viewe
c.DockerSpawner.environment = {
'GRANT_SUDO': 'yes',
'CHOWN_HOME': 'yes',
'CHOWN_EXTRA': '/home/jovyan',
'CHOWN_HOME_OPTS': '-R',
'NB_UID': 1000,
'NB_GID': 1000,
}