There are two primary ways to set the uid of the containers:
1. you can set the user-id of the container at the docker level
with extra_create_kwargs['user']
= '1234:100'
2. you can set the NB_UID environment variable *and run the container as
root*
And 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
On Tue, Aug 29, 2017 at 3:49 PM, Maria Julia Lima <[email protected]>
wrote:
> Hi
>
> Is it possible to set the NB_UID used by the container (rather than 1000,
> that is currently used by default)?
>
> Thanks
> --Julia
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jupyter/9446f8ae-4a4b-422d-abcd-556fbdacec3f%40googlegroups.com
> <https://groups.google.com/d/msgid/jupyter/9446f8ae-4a4b-422d-abcd-556fbdacec3f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/CAHNn8BWw80jJHwi-dETV8x_nLuhD52D2oggSyKEOSgDpnEXxxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.