Skip to content

Commit

Permalink
Updated to reduce image size of minimal kernel
Browse files Browse the repository at this point in the history
Contribution (c) Copyright IBM Corp. 2016
  • Loading branch information
poplav committed Jan 11, 2016
1 parent e717e31 commit e4400ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
30 changes: 8 additions & 22 deletions minimal-kernel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ USER root
# Install all OS dependencies for fully functional notebook server
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yq --no-install-recommends \
git \
vim \
wget \
build-essential \
python-dev \
python3-dev \
python3-pip \
ca-certificates \
bzip2 \
unzip \
libsm6 \
pandoc \
python3-zmq \
sudo \
&& apt-get clean

Expand All @@ -34,39 +33,26 @@ ENV SHELL /bin/bash
ENV NB_USER jovyan
ENV NB_UID 1000

# Install conda
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

# Create jovyan user with UID=1000 and in the 'users' group
# Grant ownership over the conda dir and home dir, but stick the group as root.
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
mkdir /home/$NB_USER/work && \
mkdir /home/$NB_USER/.jupyter && \
mkdir /home/$NB_USER/.local && \
chown -R $NB_USER:users $CONDA_DIR && \
chown -R $NB_USER:users /home/$NB_USER

# Install Kernel Gateway
RUN cd /tmp && \
git clone https://github.com/jupyter-incubator/kernel_gateway.git && \
cd kernel_gateway && \
python setup.py sdist && \
pip install dist/jupyter_kernel_gateway-*.tar.gz && \
rm -rf /tmp/kernel_gateway
RUN pip3 install jupyter_kernel_gateway==0.2.0

# Configure container startup
USER $NB_USER
EXPOSE 8888
WORKDIR /home/$NB_USER/work
ENTRYPOINT ["tini", "--"]
CMD ["start.sh"]
CMD ["/usr/local/bin/start-notebook.sh"]

# Add local files as late as possible to avoid cache busting
COPY start.sh /usr/local/bin/
USER root
COPY start-notebook.sh /usr/local/bin/
COPY jupyter_kernel_gateway_config.py /home/$NB_USER/.jupyter/
RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter
9 changes: 2 additions & 7 deletions minimal-kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

## What it Gives You
* [Jupyter Kernel Gateway](https://github.com/jupyter-incubator/kernel_gateway) that spawns minimal Jupyter Python kernel
* 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`
* Unprivileged user `jovyan` (uid=1000, configurable, see options) in group `users` (gid=100) with ownership over `/home/jovyan`
* [tini](https://github.com/krallin/tini) as the container entrypoint and [start.sh](./start.sh) as the default command
* Options for Port and Ip address

Expand All @@ -22,8 +21,4 @@ docker run -d -p 8888:8888 jupyter/minimal-kernel
You may customize the execution of the Docker container and the Notebook server it contains with the following optional arguments.

* `-e INTERFACE=10.10.10.10` - Configures Kernel Gateway to listen on the given interface. Defaults to '0.0.0.0', all interfaces, which is appropriate when running using default bridged Docker networking. When using Docker's `--net=host`, you may wish to use this option to specify a particular network interface.
* `-e PORT=8888` - Configures Kernel Gateway to listen on the given port. Defaults to 8888, which is the port exposed within the Dockerfile for the image. When using Docker's `--net=host`, you may wish to use this option to specify a particular port.

## Conda Environment

The default Python 3.x [Conda environment](http://conda.pydata.org/docs/using/envs.html) resides in `/opt/conda`. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in this environment.
* `-e PORT=8888` - Configures Kernel Gateway to listen on the given port. Defaults to 8888, which is the port exposed within the Dockerfile for the image. When using Docker's `--net=host`, you may wish to use this option to specify a particular port.
1 change: 0 additions & 1 deletion minimal-kernel/start.sh → minimal-kernel/start-notebook.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# 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

# Enable sudo if requested
Expand Down

0 comments on commit e4400ea

Please sign in to comment.