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

Move environment setup from start.sh to ENTRYPOINT instead of CMD #1528

Closed
manics opened this issue Nov 12, 2021 · 2 comments · Fixed by #2087
Closed

Move environment setup from start.sh to ENTRYPOINT instead of CMD #1528

manics opened this issue Nov 12, 2021 · 2 comments · Fixed by #2087
Labels
type:Enhancement A proposed enhancement to the docker images

Comments

@manics
Copy link
Contributor

manics commented Nov 12, 2021

What docker images this feature is applicable to?

  • jupyter/base-notebook
  • Notebooks that use startup hooks to configure the environment

What changes do you propose?

Split start-notebook.sh or start.sh into a script that does the environment setup in an ENTRYPOINT, and a script that does the actual notebook startup in CMD.

Originally suggested in jupyterhub/zero-to-jupyterhub-k8s#2138 (comment)

How does this change will affect users?

start-notebook.sh calls start.sh which handles a lot of setup in the Jupyter environment, including:

  • Running setup hooks such as for setting environment variables
    run-hooks /usr/local/bin/start-notebook.d
  • Customising user names and IDs when started as root
    # If the container started as the root user, then we have permission to refit
    # the jovyan user, and ensure file permissions, grant sudo rights, and such
    # things before we run the command passed to start.sh as the desired user
    # (NB_USER).
    #
    if [ "$(id -u)" == 0 ] ; then

Since start-notebook.sh is set as the CMD if someone passes any arguments when running the Docker container all this setup is ignored. For example
docker run -e NB_UID=12345 -u 0 jupyter/base-notebook jupyter-lab --debug
should change the UID from the default 1000 to 12345, but since the startup scripts aren't run this leads to an error (can't be run as root). Instead you must run
docker run -e NB_UID=12345 -u 0 jupyter/base-notebook start.sh jupyter-lab --debug

A concrete example of where this is a problem for users is in the pyspark notebook- it isn't obvious to a user that the pyspark environment is setup by a startup script rather than being baked into the Dockerfile.

Note we're working around this in JupyterHub 2.0 and Z2JH 2.0 with a breaking change: jupyterhub/zero-to-jupyterhub-k8s#2449
Instead of specifying jupyterhub-singleuser as the CMD when running the image we'll use the image's default CMD, but I think this change is still generally helpful.

@manics manics added the type:Enhancement A proposed enhancement to the docker images label Nov 12, 2021
@meeseeksmachine
Copy link

This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/pyspark-library-is-missing-from-jupyter-pyspark-notebook-when-running-with-jupyterhub-zero-to-jupyterhub-k8s/8450/6

@meeseeksmachine
Copy link

This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/cannot-use-sudo-have-root-access-using-jupyterhub-with-kubernetes/12548/5

@mathbunnyru mathbunnyru changed the title Move environment setup from start-notebook.sh to ENTRYPOINT instead of CMD [ENH] - Move environment setup from start-notebook.sh to ENTRYPOINT instead of CMD Aug 28, 2023
@mathbunnyru mathbunnyru changed the title [ENH] - Move environment setup from start-notebook.sh to ENTRYPOINT instead of CMD Move environment setup from start-notebook.sh to ENTRYPOINT instead of CMD Sep 10, 2023
@mathbunnyru mathbunnyru changed the title Move environment setup from start-notebook.sh to ENTRYPOINT instead of CMD Move environment setup from start.sh to ENTRYPOINT instead of CMD Jan 7, 2024
manics added a commit to manics/jupyter-docker-stacks that referenced this issue Jan 21, 2024
manics added a commit to manics/jupyter-docker-stacks that referenced this issue Jan 21, 2024
manics added a commit to manics/jupyter-docker-stacks that referenced this issue Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Enhancement A proposed enhancement to the docker images
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants