There are two primary ways to set the uid of the containers:
extra_create_kwargs['user'] = '1234:100'NB_UID environment variable and run the container as rootAnd there are two ways to set these values: for all users and different for each user. To do it for all users, you can do it all via config. For per-user classes, you will. need to define a small subclass of DockerSpawner to add your logic.
Some sample snippets of jupyterhub_config.py for each of the four cases:
all containers run as the same non-default uid:
c.DockerSpawner.extra_create_kwargs = {'user' : '1234:users'}
All containers start as root and set the same uid, via docker-stacks NB_UID env:
c.DockerSpawner.extra_create_kwargs = {'user' : '0'}
c.DockerSpawner.environment = {'NB_UID' : '1234'}
Set user at docker-level, different for each user
from dockerspawner import DockerSpawner
class MyDockerSpawner(DockerSpawner):
def uid_for_user(self, user):
# you implement me
return '1234'
def start(self):
self.extra_create_kwargs['user'] = self.uid_for_user(self.user)
return super().start()
c.JupyterHub.spawner_class = MyDockerSpawner
All containers start as root and set unique uids, via docker-stacks NB_UID env:
from dockerspawner import DockerSpawner
class MyDockerSpawner(DockerSpawner):
def uid_for_user(self, user):
# you implement me
return '1234'
def get_env(self):
env = super().get_env()
env['NB_UID'] = self.uid_for_user(self.user)
return env
c.DockerSpawner.extra_create_kwargs = {'user' : '0'}
c.JupyterHub.spawner_class = MyDockerSpawner
Hopefully one of those is helpful!
-Min
--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/9446f8ae-4a4b-422d-abcd-556fbdacec3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There are two primary ways to set the uid of the containers:
- you can set the user-id of the container at the docker level with
extra_create_kwargs['user'] = '1234:100'- you can set the
NB_UIDenvironment variable and run the container as root