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

Switch ENV to ARG for environment configuration in base notebook #385

Closed
jdavidheiser opened this issue May 15, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@jdavidheiser
Copy link

commented May 15, 2017

I've seen confusion around attempts to switch UIDs or usernames when using the Jupyter images (ie #360 or my own question at #376 ). Even the way it works in start.sh is to create the user in the base Dockerfile, then modify its UID when running the script. This is great, but doesn't help if you want to change the user name, or the location of files, or other things that are defined in this environment configuration.

An ideal use case would be to be able to inherit from the Jupyter images, but modify these variables, either at build time, or in a Dockerfile

Recently, in Docker version 17.05, they introduced the ability to define ARG variables before a FROM command (see discussion in moby/moby#6822). If the ENV variables were switched to ARG, with default values, they should be able to be modified from outside the Dockerfile this way.

I believe this would allow me to do something like:

ARG NB_USER=my_user_name
ARG NB_UID=1000
FROM jupyter/scipy-notebook

And have the container created with the user name and UID I want. This could also be set by specifying the --build-arg flag at build time.

I'm happy to submit a PR for this, but would like to hear thoughts on the idea first.

@parente

This comment has been minimized.

Copy link
Member

commented May 15, 2017

I understand the desire to override these at build time. Is it possible to set up the Dockerfiles so that ARG is used to allow setting these parameters at build time but ENV is also supported for users who want to use the images here as-is but configure them at run time?

@jdavidheiser

This comment has been minimized.

Copy link
Author

commented May 15, 2017

Is configuring most of these as Docker envs at runtime actually useful, since the directories and users are already created at that point? I'm thinking about the UID example, specifically, where the UID of jovyan is already set at build time, and overriding it when running the Docker container doesn't actually work unless you ALSO run start.sh as root to run a command to change the UID of the already-created user.

@parente

This comment has been minimized.

Copy link
Member

commented May 15, 2017

There have certainly been users who have reported using the start.sh script (or its many predecessors) to dynamically change the NB_UID at docker run time, particularly when using the images with JupyterHub. Whether that's still a popular use case or not is unknown. Maybe @minrk, @willingc, or @jhamrick can chime in about that.

@jdavidheiser

This comment has been minimized.

Copy link
Author

commented May 16, 2017

Oh I agree that using start.sh to change NB_UID could be useful - my point is that doesn't actually really need to depend on the environment variables as defined in the Dockerfile (with the possible exception of NB_USER)

It looks like you can use an ARG to set an ENV, using

ARG var=default_value
ENV var=${var}

would that work to allow both use cases?

@parente

This comment has been minimized.

Copy link
Member

commented May 30, 2017

It looks like the ARG+ENV will allow both use cases. If you give it a shot and see that it works properly, we'll be happy to take a PR.

@westurner

This comment has been minimized.

Copy link

commented Jan 10, 2018

👍

@parente

This comment has been minimized.

Copy link
Member

commented Dec 29, 2018

I think this was largely addressed by #720 and #731. If any options were missed, feel free to send follow-on PRs.

@parente parente closed this Dec 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.