From d6da5aef56ae3bba66a511a2913975415a0918db Mon Sep 17 00:00:00 2001 From: Raphael Das Gupta Date: Fri, 9 Oct 2020 19:07:28 +0200 Subject: [PATCH] recipes: use COPY with --chown for jovyan's files By default, Dockerfile's COPY creates files and directories with UID and GID 0. (See https://docs.docker.com/engine/reference/builder/#copy) When we put them in jovyan's $HOME or want jovyan to manipulate these files, they should be owned by jovyan instead. Specifically https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html#add-a-python-3-x-environment failed with a "permission denied" error when the code for using an environment.yml file was uncommented. I assume some of the other recipes might have failed like that, too, but I didn't test them. --- docs/using/recipes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/using/recipes.md b/docs/using/recipes.md index ae4a2854..71c563af 100644 --- a/docs/using/recipes.md +++ b/docs/using/recipes.md @@ -48,7 +48,7 @@ packages desired. Next, create a new Dockerfile like the one shown below. # Start from a core stack version FROM jupyter/datascience-notebook:9f9e5ca8fe5a # Install from requirements.txt file -COPY requirements.txt /tmp/ +COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/ RUN pip install --requirement /tmp/requirements.txt && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER @@ -60,7 +60,7 @@ For conda, the Dockerfile is similar: # Start from a core stack version FROM jupyter/datascience-notebook:9f9e5ca8fe5a # Install from requirements.txt file -COPY requirements.txt /tmp/ +COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/ RUN conda install --yes --file /tmp/requirements.txt && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER @@ -118,7 +118,7 @@ RUN conda create --quiet --yes -p $CONDA_DIR/envs/$conda_env python=$py_ver ipyt # alternatively, you can comment out the lines above and uncomment those below # if you'd prefer to use a YAML file present in the docker build context -# COPY environment.yml /home/$NB_USER/tmp/ +# COPY --chown=${NB_UID}:${NB_GID} environment.yml /home/$NB_USER/tmp/ # RUN cd /home/$NB_USER/tmp/ && \ # conda env create -p $CONDA_DIR/envs/$conda_env -f environment.yml && \ # conda clean --all -f -y