1. Introduction
Jupyter Notebook (formerly IPython notebook) is an interactive notebook that supports running more than 40 programming languages.
Jupyter Notebook is in fact a web application that lets you create and share program documents, with support for live code, mathematical equations, visualizations, and Markdown. Its uses include data cleaning and transformation, numerical simulation, statistical modeling, machine learning, and more.
2. Local Installation
2.1 Local Installation
Anaconda is recommended, as it ships with Numpy, Scipy, Matplotlib, and many other Python development packages plus Jupyter notebook.
If you use a standalone Python interpreter, you need to install Jupyter:
| |
2.2 Running Locally
| |
3. Installing Jupyter with Docker

The official project offers base-notebook, minimal-notebook, all-spark-notebook, pyspark-notebook, scipy-notebook, datascience-notebook, tensorflow-notebook, and r-notebook. Pick the image that fits your needs.
3.1 Installing Docker
| |
3.2 Running Jupyter
| |
Parameter reference:
- \ means a line continuation, splitting one command across multiple lines for readability
- -d runs the started container in the background;
- -p specifies the port; here the host’s port 8888 is mapped to the container’s port 8888;
- –user=root allows running sudo;
- -e specifies the permission-related IDs for the jovyan user;
- –name sets a name for the started container;
- -v mounts a host directory into the container. The Jupyter Docker document directory is /home/jovyan/work; so that documents survive the container being destroyed, the local directory /home/local/jupyter is mounted to /home/jovyan/work;
- -NotebookApp.password is the login password, which you can generate in IPython with the following commands:
| |
3.3 Configuring Nginx
Use the nginx -t command to find the path of the Nginx configuration file. In nginx.conf, add the following:
| |
Use nginx -s reload to restart the Nginx service and make it take effect.
4. Usage
Jupyter’s basic unit is a programming cell, that is, an In[ ]:
Jupyter has three types of cells: code, markdown cells, and raw cells, of which code cells and markdown cells are the ones commonly used.
Cells have two states, command mode and edit mode. Enter enters edit mode, ESC enters command mode, and both modes support many keyboard shortcuts.
Common command-mode shortcuts:
| |
- Inserting Markdown
Enter Markdown directly, then Run to render the result. Headings, text, videos, images and more are supported.
- Inserting LaTeX formulas
Creating an inline formula
| |
Block-level formula
| |
- Code blocks
You can output a code block directly on the page; just wrap it with ``` before and after ```.
- Embedding images
| |
- Embedding music
You can embed both local music and music from the web
| |
| |
- Embedding a local video
| |
- Embedding a web page
| |
- Embedding a link
| |
- Magic commands
Every method starting with % is what is called a magic function, i.e. a method built into IPython. Note that magic methods come in two forms, % and %%, such as %timeit and %% timeit. IPython has specific names for them: the former is called line magic and the latter cell magic. As the names suggest, the former targets a single line of command while the latter targets multiple lines.
You can view all magic commands with %lsmagic, and use ? or ?? to view information about a command — the latter lets you see the source code. For example, %alias? brings up a description of that method.
