From 3b5f7480452afb9e6b0966ce260e9f949c59acd5 Mon Sep 17 00:00:00 2001 From: Frank Sachsenheim Date: Wed, 7 Oct 2015 00:17:56 +0200 Subject: [PATCH 1/9] Moves kernel configuration and test up in Dockerfile thus image builds are faster when only notebook-code is changed --- Dockerfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef3686217..55e1a7314 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,16 @@ RUN apt-get update -qq \ && rm get-pip.py \ \ && pip2 --no-cache-dir install ipykernel \ - && pip3 --no-cache-dir install ipykernel + && pip3 --no-cache-dir install ipykernel \ + \ + && python2 -m ipykernel.kernelspec \ + && python3 -m ipykernel.kernelspec \ + \ + && pip2 install --no-cache-dir mock nose requests testpath \ + && pip3 install --no-cache-dir nose requests testpath \ + && iptest2 && iptest3 \ + && pip2 uninstall -y funcsigs mock nose pbr requests six testpath \ + && pip3 uninstall -y nose requests testpath ADD . /usr/src/jupyter-notebook @@ -55,16 +64,7 @@ RUN ln -s /usr/src/jupyter-notebook/scripts/lxc-launcher.sh /launch.sh \ \ && apt-get purge -y --auto-remove \ -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS \ - && rm -rf /var/lib/apt/lists/* \ - \ - && python2 -m ipykernel.kernelspec \ - && python3 -m ipykernel.kernelspec \ - \ - && pip2 install --no-cache-dir mock nose requests testpath \ - && pip3 install --no-cache-dir nose requests testpath \ - && iptest2 && iptest3 \ - && pip2 uninstall -y funcsigs mock nose pbr requests six testpath \ - && pip3 uninstall -y nose requests testpath + && rm -rf /var/lib/apt/lists/* VOLUME /notebooks WORKDIR /notebooks From 7a5214c8f0014565ce0f04a8f05ad1b1a33305c7 Mon Sep 17 00:00:00 2001 From: Frank Sachsenheim Date: Wed, 7 Oct 2015 01:56:31 +0200 Subject: [PATCH 2/9] Updates README.md --- README.md | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ec6dc2e68..9ddda64fa 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,34 @@ The Jupyter HTML notebook is a web-based notebook environment for interactive computing. -Dev quickstart: +## Usage + +### Local installation + +Launch with: + + $ jupyter notebook + +### In a Docker container + +If you have a [Docker daemon running](https://docs.docker.com/installation/), e.g. reachable on `localhost`, start a container with: + + $ docker run -d -p "8888:8888" --name="myproject" jupyter/notebook + +In your browser open the URL `http://localhost:8888/`. + +The image defines a [volume](https://docs.docker.com/userguide/dockervolumes/) for notebook files at `/notebooks`. +You can override it to mount a host path, e.g. the current working directory: + + $ docker run -d -p "8888:8888" -v "$(pwd):/notebooks" --name="myproject" jupyter/notebook + +## Installation + +For a local installation, make sure you have [pip installed](https://pip.readthedocs.org/en/stable/installing/) and run: + + $ pip install notebook + +### Dev quickstart * ensure that you have node/npm installed (e.g. `brew install node` on OS X) * Clone this repo and cd into it @@ -15,11 +42,7 @@ Dev quickstart: _NOTE_: For Debian/Ubuntu systems, if you're installing the system node you need to use the 'nodejs-legacy' package and not the 'node' package. -Launch with: - - jupyter notebook - -Example installation (tested on Ubuntu Trusty): +### Ubuntu Trusty ``` sudo apt-get install nodejs-legacy npm python-virtualenv python-dev @@ -31,7 +54,8 @@ pip install --pre -e . jupyter notebook ``` -For FreeBSD: +### FreeBSD + ``` cd /usr/ports/www/npm sudo make install # (Be sure to select the "NODE" option) From 8a4e14a00df45944004b5be60c00fe064f72c045 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Thu, 8 Oct 2015 00:35:59 -0400 Subject: [PATCH 3/9] Dockerfile: Set the python encoding to UTF-8. This is more of a python2 issue. In python3, *I believe* this is default. This comes up mainly when not using a TTY where stdout can have a determined encoding. See for more details ( ). --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 55e1a7314..9bf4b30ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ MAINTAINER Project Jupyter ENV LANGUAGE en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LC_ALL en_US.UTF-8 +ENV PYTHONIOENCODING UTF-8 # Python binary and source dependencies RUN apt-get update -qq \ From 456ee6c4c1ab5c3b3ddd2c7bf74c1c21ab489ba7 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 7 Oct 2015 11:58:25 -0400 Subject: [PATCH 4/9] Dockerfile: Install all `apt-get` dependencies first and purge all unneeded things. Install `pip` in a separate layer. Separate out adding link into a layer. Install ipython dependencies in another layer. --- Dockerfile | 80 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9bf4b30ab..fb34f68a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ ENV LC_ALL en_US.UTF-8 ENV PYTHONIOENCODING UTF-8 # Python binary and source dependencies -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ +RUN apt-get update -qq && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ build-essential \ ca-certificates \ curl \ @@ -32,44 +32,54 @@ RUN apt-get update -qq \ texlive-fonts-recommended \ texlive-latex-base \ texlive-latex-extra \ - zlib1g-dev \ - && rm -rf /var/lib/apt/lists/* \ - \ - `# Install the recent pip release` \ - && curl -O https://bootstrap.pypa.io/get-pip.py \ - && python2 get-pip.py \ - && python3 get-pip.py \ - && rm get-pip.py \ - \ - && pip2 --no-cache-dir install ipykernel \ - && pip3 --no-cache-dir install ipykernel \ - \ - && python2 -m ipykernel.kernelspec \ - && python3 -m ipykernel.kernelspec \ - \ - && pip2 install --no-cache-dir mock nose requests testpath \ - && pip3 install --no-cache-dir nose requests testpath \ - && iptest2 && iptest3 \ - && pip2 uninstall -y funcsigs mock nose pbr requests six testpath \ - && pip3 uninstall -y nose requests testpath + zlib1g-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +# Install the recent pip release +RUN curl -O https://bootstrap.pypa.io/get-pip.py && \ + python2 get-pip.py && \ + python3 get-pip.py && \ + rm get-pip.py + +# Install some dependencies. +RUN pip2 --no-cache-dir install ipykernel && \ + pip3 --no-cache-dir install ipykernel && \ + \ + python2 -m ipykernel.kernelspec && \ + python3 -m ipykernel.kernelspec + +# Move notebook contents into place. ADD . /usr/src/jupyter-notebook -RUN ln -s /usr/src/jupyter-notebook/scripts/lxc-launcher.sh /launch.sh \ - \ - && BUILD_DEPS="nodejs-legacy npm" \ - && apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $BUILD_DEPS \ - \ - && pip3 install --no-cache-dir --pre -e /usr/src/jupyter-notebook \ - \ - && apt-get purge -y --auto-remove \ - -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS \ - && rm -rf /var/lib/apt/lists/* +# Link entrypoint script for easy access. +RUN ln -s /usr/src/jupyter-notebook/scripts/lxc-launcher.sh /launch.sh + +# Install dependencies and run tests. +RUN BUILD_DEPS="nodejs-legacy npm" && \ + apt-get update -qq && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq $BUILD_DEPS && \ + \ + pip3 install --no-cache-dir --pre -e /usr/src/jupyter-notebook && \ + \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq $BUILD_DEPS && \ + apt-get purge -y --auto-remove \ + -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS + +# Run tests. +RUN pip2 install --no-cache-dir mock nose requests testpath && \ + pip3 install --no-cache-dir nose requests testpath && \ + \ + iptest2 && iptest3 && \ + \ + pip2 uninstall -y funcsigs mock nose pbr requests six testpath && \ + pip3 uninstall -y nose requests testpath VOLUME /notebooks WORKDIR /notebooks -ENTRYPOINT /launch.sh - EXPOSE 8888 + +ENTRYPOINT /launch.sh From fb07ccb06fe6efe1ede19142e011410b5821c83c Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 7 Oct 2015 23:34:03 -0400 Subject: [PATCH 5/9] README.md: Make note about using `docker-machine` or `boot2docker`. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9ddda64fa..ae712cf4f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ You can override it to mount a host path, e.g. the current working directory: $ docker run -d -p "8888:8888" -v "$(pwd):/notebooks" --name="myproject" jupyter/notebook +On other platforms without `docker`, this can be started using `docker-machine` +by replacing `localhost` with an IP from [`docker-machine ip `](https://docs.docker.com/machine/reference/ip/). +With the deprecated `boot2docker`, this IP will be `boot2docker ip`. + ## Installation For a local installation, make sure you have [pip installed](https://pip.readthedocs.org/en/stable/installing/) and run: From cb080df55657fed2bb3f23df0c95464dfa2b8d4f Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 7 Oct 2015 23:34:44 -0400 Subject: [PATCH 6/9] README.md: Collapse use cases. Also, show how a container can be started in a manner similar to the way a notebook would be normally. --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ae712cf4f..fc13b35cd 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,10 @@ Launch with: If you have a [Docker daemon running](https://docs.docker.com/installation/), e.g. reachable on `localhost`, start a container with: - $ docker run -d -p "8888:8888" --name="myproject" jupyter/notebook + $ docker run --rm -itP -v "$(pwd):/notebooks" jupyter/notebook In your browser open the URL `http://localhost:8888/`. - -The image defines a [volume](https://docs.docker.com/userguide/dockervolumes/) for notebook files at `/notebooks`. -You can override it to mount a host path, e.g. the current working directory: - - $ docker run -d -p "8888:8888" -v "$(pwd):/notebooks" --name="myproject" jupyter/notebook +All notebooks from your session will be saved in the current directory. On other platforms without `docker`, this can be started using `docker-machine` by replacing `localhost` with an IP from [`docker-machine ip `](https://docs.docker.com/machine/reference/ip/). From 6bd7a73456f8246cf270a6e9cbb89c6ca094828a Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 6 Oct 2015 13:17:51 -0400 Subject: [PATCH 7/9] Dockerfile: Install `tini` and use as the entrypoint to handle zombie processing reaping. Run notebook with some default arguments if no other command is provided. --- Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb34f68a6..fbf3d66da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,12 @@ RUN apt-get update -qq && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# Install Tini +RUN curl -L https://github.com/krallin/tini/releases/download/v0.6.0/tini > tini && \ + echo "d5ed732199c36a1189320e6c4859f0169e950692f451c03e7854243b95f4234b *tini" | sha256sum -c - && \ + mv tini /usr/local/bin/tini && \ + chmod +x /usr/local/bin/tini + # Install the recent pip release RUN curl -O https://bootstrap.pypa.io/get-pip.py && \ python2 get-pip.py && \ @@ -52,9 +58,6 @@ RUN pip2 --no-cache-dir install ipykernel && \ # Move notebook contents into place. ADD . /usr/src/jupyter-notebook -# Link entrypoint script for easy access. -RUN ln -s /usr/src/jupyter-notebook/scripts/lxc-launcher.sh /launch.sh - # Install dependencies and run tests. RUN BUILD_DEPS="nodejs-legacy npm" && \ apt-get update -qq && \ @@ -82,4 +85,5 @@ WORKDIR /notebooks EXPOSE 8888 -ENTRYPOINT /launch.sh +ENTRYPOINT ["tini", "--"] +CMD ["jupyter", "notebook", "--port", "8888", "--ip=*"] From 1b8eb4990237aa6546f06865c063b43b0e426898 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 7 Oct 2015 11:44:24 -0400 Subject: [PATCH 8/9] scripts/lxc-launcher.sh: Remove the LXC launcher as it is now unused. --- scripts/lxc-launcher.sh | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 scripts/lxc-launcher.sh diff --git a/scripts/lxc-launcher.sh b/scripts/lxc-launcher.sh deleted file mode 100755 index 9d12640f9..000000000 --- a/scripts/lxc-launcher.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# A wrapper script for running Jupyter notebook in a lxc-container that -# addresses two issues: -# - IPython kernels constantly crash when run with PID == 1 -# - send signals to the process for a proper shutdown when the container -# receives a TERM signal - -_terminate() { - kill -SIGINT $PID - kill -SIGINT $PID -} - -trap _terminate SIGTERM -trap _terminate SIGINT - -jupyter notebook --port 8888 --ip=* "${@}" & -PID=$! - -wait $PID -exit $? From ab7464bf5a170db5777f89364f6de58ffd896f82 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Thu, 8 Oct 2015 00:29:45 -0400 Subject: [PATCH 9/9] docs/source/changelog.rst: Note what we did. --- docs/source/changelog.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index d7fac51b4..694ca3a79 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -6,6 +6,11 @@ Jupyter notebook changelog A summary of changes in the Jupyter notebook. For more detailed information, see `GitHub `__. +4.1.x +----- + +- Properly handle reaping of zombie subprocesses. + 4.0.x -----