Jupyter Server
Introduction
Section titled “Introduction”Jupyter Server provides the backend services (core runtime, APIs, and REST endpoints) for Jupyter web applications such as Jupyter Notebook, JupyterLab, and Voilà.
See Jupyter Server Docs https://jupyter-server.readthedocs.io/en/latest/index.html See Jupyter GitHub https://github.com/jupyter-server/jupyter_server
- Jupyter Notebook migration
- Jupyter Notebook and Jupyter Server expose almost the same APIs and use very similar configuration, so a 1:1 migration is not especially difficult.
- After migrating to Jupyter Server, you can still provide the classic notebook UI through the NB Classic extension. | However, Jupyter Server is not designed to expose only the classic Notebook frontend as a separate standalone service, and JupyterLab is now the recommended interface.
See NB Classic and future Jupyter plans https://jupyter-server.readthedocs.io/en/latest/operators/migrate-from-nbserver.html#running-jupyter-notebook-on-jupyter-server
-
Configuration details
- Jupyter Server does not provide an official Docker image.
- Install the
jupyter_serverpackage with conda. - Build a Dockerfile that creates multiple conda environments so Python 2 and Python 3 IPython kernels are both available by default.
-
Dockerfile
FROM continuumio/miniconda3
# Install jupyter serverWORKDIR /appRUN conda install -c conda-forge jupyter_serverRUN conda run jupyter server --generate-config --allow-root -y
# Make RUN commands use the new environment:RUN conda create -n py38 python=3.8SHELL ["conda", "run", "-n", "py38", "/bin/bash", "-c"]RUN python3 -m pip install ipykernelRUN python3 -m ipykernel install --user --name python3 --display-name "python3.8"
RUN conda create -n py27 python=2.7SHELL ["conda", "run", "-n", "py27", "/bin/bash", "-c"]RUN python2 -m pip install ipykernelRUN python2 -m ipykernel install --user --name python2 --display-name "python2.7"
EXPOSE 8888
ENTRYPOINT ["conda", "run", "--no-capture-output", "jupyter", "server","--allow-root", "--ip=0.0.0.0"]Configuration
Section titled “Configuration”Use the configuration file generated by jupyter server --generate-config as the basis for a jupyter_server_config.py that can be mounted through a Kubernetes ConfigMap.
See Jupyter Server Full Configuration https://jupyter-server.readthedocs.io/en/latest/other/full-config.html#other-full-config
- Main contents of jupyter_server_config.py
# Configuration file for jupyter-server.
...
## Full path of a config file.# Default: ''c.JupyterApp.config_file = '<app_config_file_path>'
## Set the Access-Control-Allow-Origin header## Use '*' to allow any origin to access your server.## Takes precedence over allow_origin_pat.# Default: ''c.ServerApp.allow_origin = '<allow_origin_host>'
## Whether to allow the user to run the server as root.# Default: Falsec.ServerApp.allow_root = True
## Disable cross-site-request-forgery protection## Jupyter notebook 4.3.1 introduces protection from cross-site request# forgeries, requiring API requests to either:## - originate from pages served by this server (validated with XSRF cookie and# token), or - authenticate with a token## Some anonymous compute resources still desire the ability to run code,# completely without authentication. These services can disable all# authentication and security checks, with the full knowledge of what that# implies.# Default: Falsec.ServerApp.disable_check_xsrf = True
## The IP address the Jupyter server will listen on.# Default: 'localhost'c.ServerApp.ip = '<ip_address>'
## DEPRECATED, use root_dir.# Default: ''c.ServerApp.notebook_dir = '<notebook_dir>'
## Hashed password to use for web authentication.## To generate, type in a python/IPython shell:## from jupyter_server.auth import passwd; passwd()## The string should be of the form type:salt:hashed-password.# Default: ''c.ServerApp.password = '<type:salt:hashed-password>'
## Forces users to use a password for the Jupyter server. This is useful in a# multi user environment, for instance when everybody in the LAN can access each# other's machine through ssh.## In such a case, serving on localhost is not secure since any user can connect# to the Jupyter server via ssh.# Default: Falsec.ServerApp.password_required = True
## The port the Jupyter server will listen on.# Default: 8888c.ServerApp.port = <port_number>
## Token used for authenticating first-time connections to the server.## When no password is enabled, the default is to generate a new, random token.## Setting to an empty string disables authentication altogether, which is NOT# RECOMMENDED.# Default: '<generated>'c.ServerApp.token = '<generated>'
...Deploy
Section titled “Deploy”You can expose Jupyter Server internally through a Kubernetes Service or publish it externally through an ingress.
- Main contents of the deployment
...
spec: containers: - image: kloudbank/jupyter-server:latest name: jupyter-server imagePullPolicy: Always ports: - containerPort: 8888 # Entrypoint command command: ["conda", "run", "--no-capture-output", "jupyter", "server", "--config=/opt/jupyter_server/.jupyter/jupyter_server_config.py"]... volumeMounts: - name: persistent-storage mountPath: /opt # Config mount - name: config mountPath: /opt/jupyter_server/.jupyter volumes: - name: persistent-storage persistentVolumeClaim: claimName: jupyter-server # Cusomized config: jupyter_server_config.py - name: config configMap: name: jupyter-server items: - key: jupyter_server_config.py path: jupyter_server_config.py...Customization
Section titled “Customization”One useful pattern is to separate the interactive development environment from the execution backend. Jupyter Server can then act as the shared execution layer for multiple users, improving resource efficiency compared with running a full notebook stack per user.
The traditional Jupyter Notebook usage pattern looks like this.
- Users connect directly to the notebook web UI.

VS Code Extension
Section titled “VS Code Extension”With the Python extension for Visual Studio Code, you can use the notebook editor locally while offloading code execution to a remote Jupyter Server.
See VS Code Jupyter Notebook Support https://code.visualstudio.com/docs/python/jupyter-support
Local IDE + Remote Jupyter Server
Section titled “Local IDE + Remote Jupyter Server”- The IPython development environment is configured locally
- The remote Jupyter Server is used only for execution
- Disadvantage: each user still needs a working local environment
- Advantage: development stays local, and users connect to the remote Jupyter Server only when shared compute such as GPUs is needed
- Implementation details

VS Code Server + Remote Jupyter Server
Section titled “VS Code Server + Remote Jupyter Server”- The IPython development environment is provided through code-server
- The remote Jupyter Server is used only for execution
- Disadvantage: code-server is not completely identical to a local VS Code environment
- Advantage: the entire workflow remains browser-based
- Implementation details

Frontend Standalone App.
Section titled “Frontend Standalone App.”It is also possible to build and run a standalone frontend application by using JupyterLab frontend modules.
See developing a Jupyter standalone app https://jamiehall.eu/posts/standalone-jupyter-application
- Implementation details
