DockerSpawner/SystemUserSpawner volume mounts not owned by user

from dockerspawner import SystemUserSpawner
c.SystemUserSpawner.environment = {'NB_UMASK': '0002'}
class MyDockerSpawner(SystemUserSpawner):
    def start(self):
        self.volumes['/home/{username}/foo'] = {
            'bind': '/etc/foo',
            'mode': 'rw'
        return super().start()
c.JupyterHub.spawner_class = MyDockerSpawner

This will create a directory foo inside the user’s home directory. The problem is that the owner of this directory will be root:root, which means that the user cannot write to it. I don’t want to 'GRANT_SUDO': '1'.

Is there a way to force the owner of this directory to be {username} when it is created?

1 Like