Disk Quota using Swarm Spawner

I run jupyterhub on docker swarm with the swarm spawner. I create and bind mount the user’s home directory from a shared NFS volume that’s also mounted as a volume in the hub.

Is there any way to enforce a disk quota on each home directory? They’re all owned by the same linux user. I can switch from ext4 to XFS and set a project quota on each directory, but that requires sudo to edit the projects file, which the jupyterhub container doesn’t have.

Should I should switch to using docker volumes instead of bind mounts for the user home directory?
The bind mounts are simpler to pre-populate with files and to backup.

I’m not aware of a way to set disk quotas in Docker, so you’re limited to whatever your underlying filesystem or fileserver supports.

Sudo can be setup to allow very granular permissions, so could you give the JupyterHub user sudo permissions to run only the quota command?

Thanks, I’ll look into giving that user the ability to set quotas. Do you know if Kubernetes supports volume quotas? I might have to figure Kubernetes out one day.

Kind of- in Kubernetes you can create a PersistentVolume for each user. Depending on your k8s setup each PersistentVolume may be a virtual disk, and since each user therefore has their own disk they’ve got their own quota.

If you’re running your own k8s deployment the implementation of your Volumes may not support quotas- for instance if might be backed by dynamic NFS shares.

Thanks, good to know.