From 678b64e9e4416b5051f6797e64f49cd6db2e0cda Mon Sep 17 00:00:00 2001 From: Peter Parente Date: Wed, 16 Sep 2015 22:48:32 -0400 Subject: [PATCH 1/3] Swap tini for supervisord * Pass $@ args to start-notebook.sh * Set tini as entrypoint, but keep start-notebook.sh as easily overridable CMD * su to jovyan user within start-notebook.sh script Contribution (c) Copyright IBM Corp. 2015 --- all-spark-notebook/Dockerfile | 3 ++- datascience-notebook/Dockerfile | 3 ++- minimal-notebook/Dockerfile | 14 +++++++++++--- minimal-notebook/notebook.conf | 10 ---------- minimal-notebook/start-notebook.sh | 5 +++-- pyspark-notebook/Dockerfile | 3 ++- scipy-notebook/Dockerfile | 1 + 7 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 minimal-notebook/notebook.conf diff --git a/all-spark-notebook/Dockerfile b/all-spark-notebook/Dockerfile index a0ccb5d8..872bdb7a 100644 --- a/all-spark-notebook/Dockerfile +++ b/all-spark-notebook/Dockerfile @@ -91,4 +91,5 @@ USER root # switching at runtime. RUN $CONDA_DIR/envs/python2/bin/python \ $CONDA_DIR/envs/python2/bin/ipython \ - kernelspec install-self \ No newline at end of file + kernelspec install-self + diff --git a/datascience-notebook/Dockerfile b/datascience-notebook/Dockerfile index f1af91c2..24fff04a 100644 --- a/datascience-notebook/Dockerfile +++ b/datascience-notebook/Dockerfile @@ -96,4 +96,5 @@ USER root # switching at runtime. RUN $CONDA_DIR/envs/python2/bin/python \ $CONDA_DIR/envs/python2/bin/ipython \ - kernelspec install-self \ No newline at end of file + kernelspec install-self + diff --git a/minimal-notebook/Dockerfile b/minimal-notebook/Dockerfile index ce94b021..c6d4ebd8 100644 --- a/minimal-notebook/Dockerfile +++ b/minimal-notebook/Dockerfile @@ -22,13 +22,19 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ texlive-latex-extra \ texlive-fonts-extra \ texlive-fonts-recommended \ - supervisor \ sudo \ && apt-get clean +# Install Tini +RUN wget --quiet https://github.com/krallin/tini/releases/download/v0.6.0/tini && \ + echo "d5ed732199c36a1189320e6c4859f0169e950692f451c03e7854243b95f4234b *tini" | sha256sum -c - && \ + mv tini /usr/local/bin/tini && \ + chmod +x /usr/local/bin/tini + # Configure environment ENV CONDA_DIR /opt/conda ENV PATH $CONDA_DIR/bin:$PATH +ENV SHELL /bin/bash ENV NB_USER jovyan ENV NB_UID 1000 @@ -36,6 +42,7 @@ ENV NB_UID 1000 RUN mkdir -p $CONDA_DIR && \ echo export PATH=$CONDA_DIR/bin:'$PATH' > /etc/profile.d/conda.sh && \ wget --quiet https://repo.continuum.io/miniconda/Miniconda3-3.9.1-Linux-x86_64.sh && \ + echo "6c6b44acdd0bc4229377ee10d52c8ac6160c336d9cdd669db7371aa9344e1ac3 *Miniconda3-3.9.1-Linux-x86_64.sh" | sha256sum -c - && \ /bin/bash /Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \ rm Miniconda3-3.9.1-Linux-x86_64.sh && \ $CONDA_DIR/bin/conda install --yes conda==3.14.1 @@ -57,10 +64,11 @@ RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \ # Configure container startup EXPOSE 8888 -CMD [ "start-notebook.sh" ] +WORKDIR /home/$NB_USER/work +ENTRYPOINT ["tini", "--"] +CMD ["start-notebook.sh"] # Add local files as late as possible to avoid cache busting COPY start-notebook.sh /usr/local/bin/ -COPY notebook.conf /etc/supervisor/conf.d/ COPY jupyter_notebook_config.py /home/$NB_USER/.jupyter/ RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter \ No newline at end of file diff --git a/minimal-notebook/notebook.conf b/minimal-notebook/notebook.conf deleted file mode 100644 index a63b3596..00000000 --- a/minimal-notebook/notebook.conf +++ /dev/null @@ -1,10 +0,0 @@ -[program:notebook] -user=jovyan -umask=0002 -directory=/home/jovyan/work -command=ipython notebook -autostart=true -autorestart=true -stdout_logfile=/var/log/supervisor/%(program_name)s.log -redirect_stderr=true -environment=HOME="/home/jovyan",USER="jovyan",SHELL="/bin/bash" diff --git a/minimal-notebook/start-notebook.sh b/minimal-notebook/start-notebook.sh index f385ef32..c9f42972 100755 --- a/minimal-notebook/start-notebook.sh +++ b/minimal-notebook/start-notebook.sh @@ -11,5 +11,6 @@ if [ ! -z "$GRANT_SUDO" ]; then echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook fi -# Start supervisord in foreground, PID1 -exec supervisord -n -c /etc/supervisor/supervisord.conf +# Start the notebook server +exec su $NB_USER -c "env PATH=$PATH jupyter notebook $@" + diff --git a/pyspark-notebook/Dockerfile b/pyspark-notebook/Dockerfile index 646f9c49..c29dbef4 100644 --- a/pyspark-notebook/Dockerfile +++ b/pyspark-notebook/Dockerfile @@ -57,4 +57,5 @@ USER root # switching at runtime. RUN $CONDA_DIR/envs/python2/bin/python \ $CONDA_DIR/envs/python2/bin/ipython \ - kernelspec install-self \ No newline at end of file + kernelspec install-self + diff --git a/scipy-notebook/Dockerfile b/scipy-notebook/Dockerfile index df801ad3..c177105f 100644 --- a/scipy-notebook/Dockerfile +++ b/scipy-notebook/Dockerfile @@ -52,3 +52,4 @@ USER root RUN $CONDA_DIR/envs/python2/bin/python \ $CONDA_DIR/envs/python2/bin/ipython \ kernelspec install-self + From d425a3a502997634783ca32758912551a0fac625 Mon Sep 17 00:00:00 2001 From: Peter Parente Date: Tue, 22 Sep 2015 20:47:10 -0400 Subject: [PATCH 2/3] Mention tini and start-notebook.sh in READMEs Contribution (c) Copyright IBM Corp. 2015 --- all-spark-notebook/README.md | 1 + datascience-notebook/README.md | 1 + minimal-notebook/README.md | 1 + pyspark-notebook/README.md | 1 + r-notebook/README.md | 1 + scipy-notebook/README.md | 1 + 6 files changed, 6 insertions(+) diff --git a/all-spark-notebook/README.md b/all-spark-notebook/README.md index ffd356db..275f3b20 100644 --- a/all-spark-notebook/README.md +++ b/all-spark-notebook/README.md @@ -11,6 +11,7 @@ * Spark 1.4.1 for use in local mode or to connect to a cluster of Spark workers * Mesos client 0.22 binary that can communicate with a Mesos master * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use diff --git a/datascience-notebook/README.md b/datascience-notebook/README.md index 5fcb108b..0b6fd399 100644 --- a/datascience-notebook/README.md +++ b/datascience-notebook/README.md @@ -9,6 +9,7 @@ * plyr, devtools, dplyr, ggplot2, tidyr, shiny, rmarkdown, forecast, stringr, rsqlite, reshape2, nycflights13, caret, rcurl, and randomforest pre-installed * Julia v0.3.x with Gadfly and RDatasets pre-installed * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use diff --git a/minimal-notebook/README.md b/minimal-notebook/README.md index bfba9b0b..6c4d5598 100644 --- a/minimal-notebook/README.md +++ b/minimal-notebook/README.md @@ -6,6 +6,7 @@ * Conda Python 3.4.x * No preinstalled scientific computing packages * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](./start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use diff --git a/pyspark-notebook/README.md b/pyspark-notebook/README.md index 8e886d47..fa9295ad 100644 --- a/pyspark-notebook/README.md +++ b/pyspark-notebook/README.md @@ -8,6 +8,7 @@ * Spark 1.4.1 for use in local mode or to connect to a cluster of Spark workers * Mesos client 0.22 binary that can communicate with a Mesos master * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use diff --git a/r-notebook/README.md b/r-notebook/README.md index 9d3fdbc4..78737504 100644 --- a/r-notebook/README.md +++ b/r-notebook/README.md @@ -6,6 +6,7 @@ * Conda R v3.2.x and channel * plyr, devtools, dplyr, ggplot2, tidyr, shiny, rmarkdown, forecast, stringr, rsqlite, reshape2, nycflights13, caret, rcurl, and randomforest pre-installed * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use diff --git a/scipy-notebook/README.md b/scipy-notebook/README.md index a7bf413c..c467f369 100644 --- a/scipy-notebook/README.md +++ b/scipy-notebook/README.md @@ -6,6 +6,7 @@ * Conda Python 3.4.x and Python 2.7.x environments * pandas, matplotlib, scipy, seaborn, scikit-learn, scikit-image, sympy, cython, patsy, statsmodel, cloudpickle, dill, numba, bokeh pre-installed * Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan` and `/opt/conda` +* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * Options for HTTPS, password auth, and passwordless `sudo` ## Basic Use From 4c34446dc75417faa416537e19712974ba5ea521 Mon Sep 17 00:00:00 2001 From: Peter Parente Date: Tue, 22 Sep 2015 20:50:15 -0400 Subject: [PATCH 3/3] Fix jovyan hardcode in start-notebook.sh Contribution (c) Copyright IBM Corp. 2015 --- minimal-notebook/start-notebook.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/minimal-notebook/start-notebook.sh b/minimal-notebook/start-notebook.sh index c9f42972..9592dc4a 100755 --- a/minimal-notebook/start-notebook.sh +++ b/minimal-notebook/start-notebook.sh @@ -1,7 +1,7 @@ #!/bin/bash -# Change UID of jovyan to NB_UID if it does not match -if [ "$NB_UID" != $(id -u jovyan) ] ; then +# Change UID of NB_USER to NB_UID if it does not match +if [ "$NB_UID" != $(id -u $NB_USER) ] ; then usermod -u $NB_UID $NB_USER chown -R $NB_UID $CONDA_DIR fi