Skip to content

Instantly share code, notes, and snippets.

@phillies
Last active December 6, 2019 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillies/63cf8d880046f7c1e4777e6962902256 to your computer and use it in GitHub Desktop.
Save phillies/63cf8d880046f7c1e4777e6962902256 to your computer and use it in GitHub Desktop.
jupyterlab-matplotlib issue 154 example docker image
FROM ubuntu:bionic
SHELL ["/bin/bash", "-c"]
RUN apt update -qq && apt upgrade -y -qq
ENV CONDAROOT "/opt/conda"
WORKDIR /root/
ADD https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh /root/
RUN mkdir ~/.conda && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p $CONDAROOT && \
rm -rf Miniconda3-latest-Linux-x86_64.sh && \
source $CONDAROOT/etc/profile.d/conda.sh
# add conda to the path
ENV PATH $CONDAROOT/bin:$PATH
# Install pytorch and fastai through conda
RUN conda update -n base -c defaults conda && \
conda create -n torch -y python=3.7 && \
conda install -n torch -c conda-forge jupyterlab jupyter_contrib_nbextensions nodejs ipympl widgetsnbextension
# activate the torch environment to install further packages with pip which are not available or outdated on conda
ENV PATH $CONDAROOT/envs/torch/bin:$PATH
RUN echo "source activate torch" >> ~/.bashrc
RUN jupyter-lab --generate-config && \
sed -i '/c.NotebookApp.open_browser/c\c.NotebookApp.open_browser = False' ~/.jupyter/jupyter_notebook_config.py && \
sed -i '/c.NotebookApp.quit_button/c\c.NotebookApp.quit_button = True' ~/.jupyter/jupyter_notebook_config.py && \
sed -i '/c.NotebookApp.token/c\c.NotebookApp.token = "'""'"' ~/.jupyter/jupyter_notebook_config.py && \
sed -i '/c.NotebookApp.ip/c\c.NotebookApp.ip = "'"0.0.0.0"'"' ~/.jupyter/jupyter_notebook_config.py && \
sed -i '/c.NotebookApp.allow_root/c\c.NotebookApp.allow_root = True' ~/.jupyter/jupyter_notebook_config.py && \
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib
# Make port 8888 available to the world outside this container
EXPOSE 8888
# Run the torchtest script when the container launches (and no other command is given)
CMD ["jupyter-lab"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment