Jupyter Dockerised

These are notes on how to build and run a Dockerised Jupyter Notebook server on Windows. Jupyter Notebooks is an open source web application which allows people to create and share scientific computing results with each other:

The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

Docker on Windows

Docker runs on Windows via a VM called the Docker Machine, typically in the Virtual Box hypervisor. To run Docker on Windows you will need Virtual Box and Docker Machine, these are helpfully installed by Docker Toolbox.

Running the container on Windows

Install Docker Toolbox and run the Docker QuickStart Terminal. This creates a ‘default’ Docker Machine and will configure it for use. Next clone the JupyterServer repo which is based on docker-stacks.

git clone https://github.com/bayesjumping/JupyterServer.git

In the Docker Quick Start Terminal cd into the source directory. Stop the Docker Machine and create a shared folder between Windows and Virtual Box.

docker-machine stop default
/C/Program\ Files/Oracle/VirtualBox/VBoxManage sharedfolder add default --name notebooks --hostpath `pwd` --automount
docker-machine start default

Create a folder in Docker Machine to hold the Notebooks. Synchronize this folder with the host Windows folder.

docker-machine ssh default 'mkdir notebooks'
docker-machine ssh default 'sudo mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` notebooks /home/docker/notebooks'

Note: You may need to run this step if you restart the Docker Machine.

Create the container from the Dockerfile. This may take some time on the first install.

docker build -t bayesjumping/jupyterserver:0.1 .

Run the container.

docker-machine ssh default 'docker run -d -p 8888:8888 -v /home/docker/notebooks:/home/jovyan/work --name=notebooks bayesjumping/jupyterserver:0.1 start-notebook.sh'

Check the Docker Machine’s ip docker-machine ip defaultand use this ip with port 8888 appended to use Jupyter (i.e. http://192.168.99.100:8888/). You should have a working Jupyter server with both the Python and R kernals.

Jupyter