DockerSpawner mounting shared folder - files missing after host updated

I’m using Jupyterhub with dockerspawner, and am able to mount specific host folders (read only) based on information about the user that we pass in with the create server API call. We set up the mount in an overwritten start, similar to what was proposed here: Mount different volumes based on userlist/group · Issue #239 · jupyterhub/dockerspawner · GitHub

class MyDockerSpawner(DockerSpawner):
    def start(self, image=None, extra_create_kwargs=None, extra_host_config=None):
        # We define the data_dir then:
        self.volumes[data_dir] = {
            "bind": "/home/jovyan/work/shared_data",
            "mode": "ro",
        }
        return super().start(
            image=image,
            extra_create_kwargs=extra_create_kwargs,
            extra_host_config=extra_host_config,
        )

The problem is that we regularly update the contents of the mounted folders in a separate process. So when the notebook server first starts it can access all of the files in the mounted directories, but once they’ve been updated - those folders seems to disappear.

After folders have been deleted and recreated (there should be two sub directories shown):

The newly recreated directories look to have all the same permissions as the previous ones (indeed they are all created by the same process). Some help would be much appreciated, as I just can’t understand why mounting a shared directory doesn’t seem to be truly shared.

1 Like

Are you changing the contents of data_dir, or are you modifying data_dir itself? What’s the underlying filesystem that data_dir is on?

Thanks, it turns out that I was modifying data_dir itself. I thought I was just changing the directory contents - but I was actually replacing the data_dir folder. Only discovered that once I got it running on a NFS and it returned an error. Changed the sync process to not replace or delete the mounted directory and it now works!

1 Like