Skip to content

Commit

Permalink
Add initial_user traitlet to change user that container is started with
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwiese committed Jul 28, 2023
1 parent 7d72e76 commit 213c12e
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit 213c12e

Please sign in to comment.