Mount different volumes based on userlist/group
See original GitHub issueIs it possible to mount different images based on the username/group (provided by ldapauthenticator in my case).
I currently have a config as follows, but would need a 4th (shared) volume for a selected group of users.
c.DockerSpawner.volumes = {
'jupyterhub-userhome-{username}': { 'bind': notebook_dir , 'mode': 'rw'},
'jupyterhub-user-{username}': { 'bind': notebook_dir + 'work/' , 'mode': 'rw'},
'juypterhub-shared-data': { 'bind': '/home/jovyan/work/shared-ro', 'mode': 'ro'},
}
I wouldn’t mind to hardcode these users in the config as they almost never change.
I tried using a dict using templating to select the correct value - but it seems that templating does not apply here and jupyterhub fails to start.
volumedict = {'superuser': {
'jupyterhub-userhome-{username}': { 'bind': notebook_dir , 'mode': 'rw'},
'jupyterhub-user-{username}': { 'bind': notebook_dir + 'work/' , 'mode': 'rw'},
'juypterhub-shared-data': { 'bind': '/home/jovyan/work/shared-ro', 'mode': 'ro'},
'jupyterhub_test_mount': { 'bind': '/home/jovyan/test', 'mode': 'rw'},
},
'other': {
'jupyterhub-userhome-{username}': { 'bind': notebook_dir , 'mode': 'rw'},
'jupyterhub-user-{username}': { 'bind': notebook_dir + 'work/' , 'mode': 'rw'},
'juypterhub-shared-data': { 'bind': '/home/jovyan/work/shared-ro', 'mode': 'ro'},
}
}
c.DockerSpawner.volumes = volumedict['{% "superuser" if username == "xmatthias" else "other"%}']
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Docker-compose set user and group on mounted volume
To achieve the desired behavior without changing owner / permissions on the host system do the following steps.
Read more >What is a prescriptive way for managing the permissions for ...
Use the same user and group between containers and mounted volumes. Use ACLs to control the permissions. Is there a recommended approach for ......
Read more >Mounting volume/partition with permissions for user
Some solutions I've read about include: changing ownership of the mount point with chown. adding group write permissions with chmod.
Read more >5.3.5. Displaying Volume Groups Red Hat Enterprise Linux 6
The vgdisplay command displays volume group properties (such as size, extents, number of physical volumes, and so on) in a fixed form. The...
Read more >Volumes - Docker Documentation
The following example modifies the one above but mounts the directory as a read-only volume, by adding ro to the (empty by default)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@xmatthias this now works for me. Hope it helps you!
@jameholme If you just want a single shared folder that all users have read/write access to, you could add this to your
jupyterhub_config.py
:This assumes you already have
'jupyterhub-user-{username}':'/home/jovyan/work',
as a docker volume per user… if not, just omit that bit.The earlier code is for having separate volumes for groups/teams. If you don’t need that, you don’t need any of that code, and just the line above.
Note: depending on your setup, you may have to create the
jupyterhub-shared
volume from the docker cli before it can be used, and I’ve also previously had to manually set file permissions inside the volume before users could actually write to it. Again, this may depend on your setup and configuration. Hope this helps!