Commit 2c80cf35 authored by Peter Parente's avatar Peter Parente Committed by GitHub

Merge pull request #509 from tlinnet/master

 Fix for granting SUDO to jovyan user and run bash commands.
parents 0b3ec811 ac82cac7
...@@ -7,9 +7,25 @@ Opinionated stacks of ready-to-run Jupyter applications in Docker. ...@@ -7,9 +7,25 @@ Opinionated stacks of ready-to-run Jupyter applications in Docker.
## Quick Start ## Quick Start
If you're familiar with Docker, have it configured, and know exactly what you'd like to run, this one-liner should work in most cases: If you're familiar with Docker, have it configured, and know exactly what you'd like to run, one of these commands should get you up and running:
``` ```
# Run an ephemeral Jupyter Notebook server in a Docker container in the terminal foreground.
# Note that any work saved in the container will be lost when it is destroyed with this config.
# -ti: pseudo-TTY+STDIN open.
# -rm: remove the container on exit.
# -p: publish port to the host
docker run -ti --rm -p 8888:8888 jupyter/<your desired stack>:<git-sha-tag>
# Run a Jupyter Notebook server in a Docker container in the terminal foreground.
# Any files written to ~/work in the container will be saved to the current working
# directory on the host.
docker run -ti --rm -p 8888:8888 -v "$PWD":/home/jovyan/work jupyter/<your desired stack>:<git-sha-tag>
# Run an ephemeral Jupyter Notebook server in a Docker container in the background.
# Note that any work saved in the container will be lost when it is destroyed with this config.
# -d: detach, run container in background.
# -P: Publish all exposed ports to random ports
docker run -d -P jupyter/<your desired stack>:<git-sha-tag> docker run -d -P jupyter/<your desired stack>:<git-sha-tag>
``` ```
...@@ -27,6 +43,19 @@ Here's a diagram of the `FROM` relationships between all of the images defined i ...@@ -27,6 +43,19 @@ Here's a diagram of the `FROM` relationships between all of the images defined i
[![Image inheritance diagram](internal/inherit-diagram.svg)](http://interactive.blockdiag.com/?compression=deflate&src=eJyFzTEPgjAQhuHdX9Gws5sQjGzujsaYKxzmQrlr2msMGv-71K0srO_3XGud9NNA8DSfgzESCFlBSdi0xkvQAKTNugw4QnL6GIU10hvX-Zh7Z24OLLq2SjaxpvP10lX35vCf6pOxELFmUbQiUz4oQhYzMc3gCrRt2cWe_FKosmSjyFHC6OS1AwdQWCtyj7sfh523_BI9hKlQ25YdOFdv5fcH0kiEMA) [![Image inheritance diagram](internal/inherit-diagram.svg)](http://interactive.blockdiag.com/?compression=deflate&src=eJyFzTEPgjAQhuHdX9Gws5sQjGzujsaYKxzmQrlr2msMGv-71K0srO_3XGud9NNA8DSfgzESCFlBSdi0xkvQAKTNugw4QnL6GIU10hvX-Zh7Z24OLLq2SjaxpvP10lX35vCf6pOxELFmUbQiUz4oQhYzMc3gCrRt2cWe_FKosmSjyFHC6OS1AwdQWCtyj7sfh523_BI9hKlQ25YdOFdv5fcH0kiEMA)
[Click here for a commented build history of each image, with references to tag/SHA values.](https://github.com/jupyter/docker-stacks/wiki/Docker-build-history)
The following are quick-links to READMEs about each image and their Docker image tags on Docker Cloud:
* base-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/base-notebook), [SHA list](https://hub.docker.com/r/jupyter/base-notebook/tags/)
* minimal-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/minimal-notebook), [SHA list](https://hub.docker.com/r/jupyter/minimal-notebook/tags/)
* scipy-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/scipy-notebook), [SHA list](https://hub.docker.com/r/jupyter/scipy-notebook/tags/)
* r-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/r-notebook), [SHA list](https://hub.docker.com/r/jupyter/r-notebook/tags/)
* tensorflow-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/tensorflow-notebook), [SHA list](https://hub.docker.com/r/jupyter/tensorflow-notebook/tags/)
* datascience-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook), [SHA list](https://hub.docker.com/r/jupyter/datascience-notebook/tags/)
* pyspark-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/pyspark-notebook), [SHA list](https://hub.docker.com/r/jupyter/pyspark-notebook/tags/)
* all-spark-notebook: [README](https://github.com/jupyter/docker-stacks/tree/master/all-spark-notebook), [SHA list](https://hub.docker.com/r/jupyter/all-spark-notebook/tags/)
## Stacks, Tags, Versioning, and Progress ## Stacks, Tags, Versioning, and Progress
Starting with [git commit SHA 9bd33dcc8688](https://github.com/jupyter/docker-stacks/tree/9bd33dcc8688): Starting with [git commit SHA 9bd33dcc8688](https://github.com/jupyter/docker-stacks/tree/9bd33dcc8688):
......
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
set -e set -e
# Exec the specified command or fall back on bash
if [ $# -eq 0 ]; then
cmd=bash
else
cmd=$*
fi
# Handle special flags if we're root # Handle special flags if we're root
if [ $(id -u) == 0 ] ; then if [ $(id -u) == 0 ] ; then
...@@ -45,20 +52,22 @@ if [ $(id -u) == 0 ] ; then ...@@ -45,20 +52,22 @@ if [ $(id -u) == 0 ] ; then
echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
fi fi
# Exec the command as NB_USER # Exec the command as NB_USER with the PATH and the rest of
echo "Execute the command: $*" # the environment preserved
exec su $NB_USER -c "env PATH=$PATH $*" echo "Executing the command: $cmd"
exec sudo -E -H -u $NB_USER PATH=$PATH $cmd
else else
if [[ ! -z "$NB_UID" && "$NB_UID" != "$(id -u)" ]]; then if [[ ! -z "$NB_UID" && "$NB_UID" != "$(id -u)" ]]; then
echo 'Container must be run as root to set $NB_UID' echo 'Container must be run as root to set $NB_UID'
fi fi
if [[ ! -z "$NB_GID" && "$NB_GID" != "$(id -g)" ]]; then if [[ ! -z "$NB_GID" && "$NB_GID" != "$(id -g)" ]]; then
echo 'Container must be run as root to set $NB_GID' echo 'Container must be run as root to set $NB_GID'
fi fi
if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then
echo 'Container must be run as root to grant sudo permissions' echo 'Container must be run as root to grant sudo permissions'
fi fi
# Exec the command
echo "Execute the command: $*" # Execute the command
exec $* echo "Executing the command: $cmd"
exec $cmd
fi fi
...@@ -24,7 +24,7 @@ def test_unsigned_ssl(container, http_client): ...@@ -24,7 +24,7 @@ def test_unsigned_ssl(container, http_client):
container.run( container.run(
environment=['GEN_CERT=yes'] environment=['GEN_CERT=yes']
) )
# NOTE: The requests.Session backing the http_client fixture does not retry # NOTE: The requests.Session backing the http_client fixture does not retry
# properly while the server is booting up. An SSL handshake error seems to # properly while the server is booting up. An SSL handshake error seems to
# abort the retry logic. Forcing a long sleep for the moment until I have # abort the retry logic. Forcing a long sleep for the moment until I have
# time to dig more. # time to dig more.
...@@ -40,7 +40,7 @@ def test_uid_change(container): ...@@ -40,7 +40,7 @@ def test_uid_change(container):
tty=True, tty=True,
user='root', user='root',
environment=['NB_UID=1010'], environment=['NB_UID=1010'],
command=['start.sh', 'id && touch /opt/conda/test-file'] command=['start.sh', 'bash', '-c', 'id && touch /opt/conda/test-file']
) )
# usermod is slow so give it some time # usermod is slow so give it some time
c.wait(timeout=120) c.wait(timeout=120)
......
...@@ -47,7 +47,7 @@ RUN conda install --quiet --yes \ ...@@ -47,7 +47,7 @@ RUN conda install --quiet --yes \
# Activate ipywidgets extension in the environment that runs the notebook server # Activate ipywidgets extension in the environment that runs the notebook server
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \ jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
# Also activate ipywidgets extension for JupyterLab # Also activate ipywidgets extension for JupyterLab
jupyter labextension install @jupyter-widgets/jupyterlab-manager && \ jupyter labextension install @jupyter-widgets/jupyterlab-manager@^0.31.0 && \
npm cache clean && \ npm cache clean && \
rm -rf $CONDA_DIR/share/jupyter/lab/staging && \ rm -rf $CONDA_DIR/share/jupyter/lab/staging && \
fix-permissions $CONDA_DIR fix-permissions $CONDA_DIR
......
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