In this scenario, you will run a Jupyter Notebook in a Docker Container.
The underlying Docker Container Image is jupyter/scipy-notebook. It contains these contents:
- Minimally-functional Jupyter Notebook server (e.g., no pandoc for saving notebooks as PDFs)
- Miniconda Python 3.x in /opt/conda
- Pandoc and TeX Live for notebook document conversion
- git, emacs, jed, nano, and unzip
- pandas, numexpr, matplotlib, scipy, seaborn, scikit-learn, scikit-image, sympy, cython, patsy, statsmodel, cloudpickle, dill, numba, bokeh, sqlalchemy, hdf5, vincent, beautifulsoup, protobuf, and xlrd packages
- ipywidgets for interactive visualizations in Python notebooks
- Facets for visualizing machine learning datasets
For details on the Jupyter Docker Stacks libary of container images
You will then add a number of supporting libraries into the running container. This scenario adds these libraries after the container has been started:
- Gender Guesser
The scenario also deploys a predefined Jupyter Notebook by cloning a GitHub repository. You are free to add additional notebooks in a similar way - or upload them from your own collection.
Finally, you will access the Jupyter Notebook and start playing with it.
Step 1 - Run the Jupyter Notebook environment
You will now run a Docker container for Jupyter Notebook. Note: this may take up to 3 minutes, because of the size of the container image.
Run the Jupyter Notebook
Run the Jupyter Notebook container image:
docker run -p 8888:8888 -d --name jupyter jupyter/scipy-notebook:83ed2c63671f
Further prepare the container
To prepare the container we will run a script inside the container to install several Python packages
Run this script to execute these steps:
- copy the script prepareContainer.sh into the container
- copy the script, make the copy executable and then run the script inside the container - this will install several Python packages using pip
- restart the container
Notes on what is happening under the covers
These are the individual steps inside this script. You do not have to execute them - because they are in the runPrep.sh script.
First, copy the script into the container
docker cp prepareContainer.sh jupyter:/home/jovyan/prepareContainerRoot.sh
This will copy the local file prepareContainer.sh into the container's directory
/home/jovyan as prepareContainerRoot.sh; it will be a root owned file that cannot be run straightaway.
Next, copy the script, make the copy executable and then run the script inside the container:
docker exec -d jupyter bash -c 'cp ~/prepareContainerRoot.sh ~/prepareContainer.sh && chmod +x ~/prepareContainer.sh'
Next, run the script inside the container:
docker exec -d jupyter sh /home/jovyan/prepareContainer.sh
Finally restart the docker container
docker restart jupyter