Commit 80c84752 authored by Peter Parente's avatar Peter Parente

Improve start-notebook.sh checks

* Only create jovyan and set perms if user does not exist
* Allow docker host mount for NB_WORK: copy skel files if useradd fails because home dir already exists

Contribution (c) Copyright IBM Corp. 2015
parent c4616560
...@@ -27,7 +27,9 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ ...@@ -27,7 +27,9 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \
# Configure docker environment # Configure docker environment
ENV CONDA_DIR /opt/conda ENV CONDA_DIR /opt/conda
ENV NB_USER jovyan ENV NB_USER jovyan
ENV WORK /home/$NB_USER/work ENV NB_HOME /home/$NB_USER
ENV NB_WORK $NB_HOME/work
ENV WORK $NB_WORK
ENV PATH $CONDA_DIR/bin:$PATH ENV PATH $CONDA_DIR/bin:$PATH
# Install conda # Install conda
......
#!/bin/bash #!/bin/bash
set -e
# Create non-root NB_USER, member of group "users" # Create non-root NB_USER if one doesn't exist
useradd -m -s /bin/bash -u ${NB_UID:-1000} -G users $NB_USER id -u $NB_USER && user_exists=true
if [ -z "$user_exists" ] ; then
useradd -m -s /bin/bash -u ${NB_UID:-1000} $NB_USER
# Allow "users" group to update conda root env # Setup a work directory rooted in the NB_USER home
chown -R root.users $CONDA_DIR mkdir -p $WORK
chmod -R g+w $CONDA_DIR chown -R jovyan.jovyan $NB_HOME
# Setup a work directory rooted in the NB_USER home # Allow "jovyan" group to update conda root env
mkdir -p $WORK chown -R root.jovyan $CONDA_DIR
chown root.users $WORK chmod g+w $CONDA_DIR
chmod g+w $WORK fi
# Copy skeleton files if useradd didn't do it (e.g., volume mounted dir
# residing in /home/jovyan prevented it)
if [ ! -d $NB_HOME/.jupyter ]; then
cp -r /etc/skel/. $NB_HOME
chown -R jovyan.jovyan $NB_HOME
fi
# Enable sudo if requested # Enable sudo if requested
if [ ! -z "$GRANT_SUDO" ]; then if [ ! -z "$GRANT_SUDO" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment