【问题标题】:Jupyterhub/singleuser shared volumeJupyterhub/单用户共享卷
【发布时间】:2017-07-08 12:01:27
【问题描述】:

我正在尝试在 Ubuntu 16.04 上设置一个 Jupyterhub 服务器,与https://github.com/minrk/jupyterhub-demo 非常相似。

我使用https://github.com/jupyterhub/dockerspawner#data-persistence-and-dockerspawner 此处给出的提示更改了 jupyterhub_config.py 以支持持久存储:

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 }

但是,我想为用户团队添加一个共享的“团队”卷。我有一个包含用户名(键)和团队名(值)的字典,用于将用户映射到团队。

理想情况下,我会这样说:

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

但我不知道如何将另一个 {name} 映射传递给 dockerspawner。

我试着摆弄这些,但到目前为止无济于事:

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")

有什么想法吗?

P.S.:这个问题和Shared, writable folders in jupyterhub有些关系

【问题讨论】:

    标签: python docker ubuntu-16.04 jupyter jupyterhub


    【解决方案1】:

    来自@minrk 的回复,您在此处发布几周后在GitHub 收到。

    对于未在默认配置对象中公开的更高级逻辑,您还可以在配置文件中子类化 DockerSpawner:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多