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.
## 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>
```
......@@ -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)
[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
Starting with [git commit SHA 9bd33dcc8688](https://github.com/jupyter/docker-stacks/tree/9bd33dcc8688):
......
......@@ -4,6 +4,13 @@
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
if [ $(id -u) == 0 ] ; then
......@@ -45,9 +52,10 @@ if [ $(id -u) == 0 ] ; then
echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
fi
# Exec the command as NB_USER
echo "Execute the command: $*"
exec su $NB_USER -c "env PATH=$PATH $*"
# Exec the command as NB_USER with the PATH and the rest of
# the environment preserved
echo "Executing the command: $cmd"
exec sudo -E -H -u $NB_USER PATH=$PATH $cmd
else
if [[ ! -z "$NB_UID" && "$NB_UID" != "$(id -u)" ]]; then
echo 'Container must be run as root to set $NB_UID'
......@@ -58,7 +66,8 @@ else
if [[ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]]; then
echo 'Container must be run as root to grant sudo permissions'
fi
# Exec the command
echo "Execute the command: $*"
exec $*
# Execute the command
echo "Executing the command: $cmd"
exec $cmd
fi
......@@ -40,7 +40,7 @@ def test_uid_change(container):
tty=True,
user='root',
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
c.wait(timeout=120)
......
......@@ -47,7 +47,7 @@ RUN conda install --quiet --yes \
# Activate ipywidgets extension in the environment that runs the notebook server
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
# 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 && \
rm -rf $CONDA_DIR/share/jupyter/lab/staging && \
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