Docker knows about images that contain the entire software stack necessary to run an application. We need to build an image with a Notebook and place this in Docker.
We need to download all of the Jupyter-Docker coding necessary. In the Docker Terminal window, we run the following command:
$ docker pull jupyter/all-spark-notebook Using default tag: latest latest: Pulling from jupyter/all-spark-notebook 8b87079b7a06: Pulling fs layer 872e508604af: Pulling fs layer 8e8d83eda71c: Pull complete ...
This is a large download that will take some time. It is downloading and installing all of the possibly necessary components needed to run Jupyter in an image. Remember that each image is completely self-contained so each image has ALL of the software needed to run Jupyter.
Once the download is complete, we can start an image for our Notebook using a command such as the following:
docker run -d -p 8888:8888 -v /disk-directory:/virtual-notebook jupyter/all-spark-notebook The parts of this command are:
- docker run: The command to Docker to start executing an image.
- -d: Runs the image as a server (daemon) that will continue running until manually stopped by the user.
- -p 8888:8888: Exposes the internal port 8888 to external users with the same port address. Notebooks use port 8888 by default already, so we are saying just expose the same port.
- -v /disk-directory:/virtual-notebook: Takes the Notebook from the disk-directory and exposes it as the virtual-notebook name.
- The last argument is to use all-spark-notebook as the basis for this image. In my case, I used the following command:
$ docker run -d -p 8888:8888 -v /Users/dtoomey:/dan-notebook jupyter/all-spark-notebook b59eaf0cae67506e4f475a9861f61c01c5af3556489992104c4ce39343e8eb02
The big hex number displayed is the image identifier. We can make sure the image is running using the docker ps -l command that lists out the images in our Docker:
$ docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b59eaf0cae67 jupyter/all-spark-notebook "tini -- start-notebo" 8 seconds ago Up 7 seconds 0.0.0.0:8888->8888/tcp modest_bardeen
The parts of the display are as follows:
- The first name b59... is the assigned ID of the container. Each image in Docker is assigned to a container.
- The image is jupyter/all-spark-notebook, and it contains all of the software needed to run your Notebook.
- The command is telling Docker to start the image.
- The port access point is as we expected: 8888.
- Lastly, Docker assigns random names to every running image modest_bardeen (not sure why they do this).
If we try to access Docker Jupyter at this point, we will be asked to set up security for the system, as in this display:
Once we have set up security, we should be able to access the Notebook from a browser at http:// 127.0.0.1:8888. We saw the preceding IP address when Docker started (0.0.0.0) and we are using port 8888 as we specified:
You can see the URL in the top-left corner. Beneath that, we have a standard empty Notebook. The Docker image used has all of the latest versions, so you do not have to do anything special to get updated software or components for your Notebook. You can see the language options available by pulling down the New menu: