Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial_user traitlet to change user that container is started with #492

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dockerspawner/dockerspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ def _port_default(self):
def _ip_default(self):
return "0.0.0.0"

initial_user = Unicode(
"jovyan",
help="""
The initial user with which to start the container

The [default user for Jupyter Docker stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#jupyter-docker-stacks-foundation) is 'jovyan'

You may need to set this value to 'root', which is equivalent to
`docker run --user root`. This is necessary when e.g. changing jovyan's
default UID or home directory permissions

Jupyter Docker stacks will switch back to jovyan before starting the notebook server (e.g. JupyterLab)
The end-user within the container *will not* be the user set here, unless you are using a modified image
""",
config=True,
)

container_image = Unicode(
"jupyterhub/singleuser:%s" % _jupyterhub_xy,
help="Deprecated, use `DockerSpawner.image.`",
Expand Down Expand Up @@ -1123,6 +1140,7 @@ async def create_object(self):
volumes=self.volume_mount_points,
name=self.container_name,
command=(await self.get_command()),
user=self.initial_user,
)

# ensure internal port is exposed
Expand Down
Loading