1

I'm trying to setup a Jupyterhub server on Ubuntu 16.04, much along the lines of https://github.com/minrk/jupyterhub-demo.

I changed the jupyterhub_config.py to support persistent storage using the tips given here https://github.com/jupyterhub/dockerspawner#data-persistence-and-dockerspawner:

notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work'
c.DockerSpawner.notebook_dir = notebook_dir
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }

However, I would like to add a shared "team" volume for teams of users. I have a dictionary with usernames (keys) and teamnames (values) to map users to teams.

Ideally I would state something like:

c.DockerSpawner.volumes = { 
    'jupyterhub-user-{username}': notebook_dir, 
    'jupyterhub-team-{teamname}': os.path.join(notebook_dir, 'shared' 
}

But I have no clue as to how to pass another {name} mapping to dockerspawner.

I tried fiddling with these, but so far to no avail:

c.DockerSpawner. ...
extra_create_kwargs = Dict(config=True, help="Additional args to pass for container create")
extra_start_kwargs = Dict(config=True, help="Additional args to pass for container start")
extra_host_config = Dict(config=True, help="Additional args to create_host_config for container create")

Any ideas?

P.S.: This question is somewhat related to Shared, writable folders in jupyterhub

1 Answers1

2

From the reply by @minrk you received on GitHub a couple of weeks after posting here.

For more advanced logic not exposed in the default config objects, you can also subclass DockerSpawner in your config file:

from dockerspawner import DockerSpawner
class MyDockerSpawner(DockerSpawner):
    def start(self):
        # username is self.user.name
        team = 'myteam'
        # add team volume to volumes
        self.volumes['jupyterhub-team-{}'.format(team)] = '/home/shared'
        return super().start()

c.JupyterHub.spawner_class = MyDockerSpawner
dijksterhuis
  • 1,225
  • 11
  • 25
harschware
  • 13,006
  • 17
  • 55
  • 87