Numpy Jupyter notebook on Docker

Machine Learning and Data Analytics are becoming quite popular for main stream data processing. In this article we learn how to run numpy programs on Jupyter which is served from inside a docker container.

Setup Docker

we assume you have the latest version of docker running on your compute. In our case it is docker for mac

Make sure you have access to the docker binary

docker --version
Docker version 17.09.0-ce, build afdb6d4

Download Run Docker Jupyter Image

Run the jupyter/scipy-notebook in the detached mode. Please note the container port 8888 is mapped to host port of 8888.

docker run -d -p 8888:8888 jupyter/scipy-notebook

You can inspect the container running and get the container id

docker ps -a


CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS                     PORTS                     NAMES
4bdd0e4841e0        jupyter/scipy-notebook   "tini -- start-not..."   About a minute ago   Up About a minute>8888/tcp    mystifying_almeida

Get the Security token

Since the jupyter notebooks from this image have a security token associated, execute the following command to get the token

docker exec 4bdd0e4841e0 jupyter notebook list

Output of the command above will give the URL with security token

Currently running servers:

http://localhost:8888/?token=a37c45becfd981ffeb2fdca9b82419bd697e9a8b4b5bf25b :: /home/jovyan

Access Jupyter Notebook

  1. Direct the Host browser at the URL above http://localhost:8888/?token=a37c45becfd981ffeb2fdca9b82419bd697e9a8b4b5bf25b
../_images/jupyter_one.png ../_images/jupyter_np_two.png
  1. Create a new Python3 notebook
  1. Add following basic numpy code
  1. Rename and save the notebook

Restart Docker and Check notebook still exists

docker stop cf66ff4874b9

docker start cf66ff4874b9


In this article we learnt how to use a Jupyter notebook running inside a docker image to run numpy samples.