Sharing notebooks between system users

I’m using SystemUserSpawner(DockerSpawner) to give users containers based on users existing on the host system. Everyone has a separate user on the system, but all users belong to the group users.

I’ve created a directory /srv/shared on the host which is mounted to all user containers. I want users to be able to share notebooks with read/write capability by placing them in this directory. I set the owner of this directory to root:users and the permissions to 775, so that everyone in the group users can read/write to the directory.

The problem I am having is that Jupyter writes notebook files to this directory with mode 644, which means that members of group users cannot write to them. Is there a clever way to change this so that the notebook files are written as 664, and the .ipynb_checkpoints directory written as 775, or something similar to this? Maybe there is a more sensible approach that I have missed.

This is most likely something you’ll have to configure inside your Docker image. This article on umask should help you out:

You’re a genius. I added this to my jupyterhub_config.py:

c.SystemUserSpawner.environment = {'NB_UMASK': '0002'}