• This repository has been archived on 25/Jan/2018
  • Stars
    star
    528
  • Rank 83,941 (Top 2 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created about 10 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Creates temporary Jupyter Notebook servers using Docker containers. [DEPRECATED - See BinderHub project]

tmpnb, the temporary notebook service

Launches "temporary" Jupyter notebook servers.

WARNING: tmpnb is no longer actively maintained.

We recommend you switch to using JupyterHub.

Configuration option 1:

Configuration option 2:


tmpnb architecture

tmpnb launches a docker container for each user that requests one. In practice, this gets used to provide temporary notebooks, demo the IPython notebook as part of a Nature article, or even provide Jupyter kernels for publications.

People have used it at user groups, meetups, and workshops to provide temporary access to a full system without any installation whatsoever.

Quick start

Get Docker, then:

docker pull jupyter/minimal-notebook
export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=tmpnb -v /var/run/docker.sock:/docker.sock jupyter/tmpnb python orchestrate.py --container-user=jovyan --command='jupyter notebook --no-browser --port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} --NotebookApp.port_retries=0 --NotebookApp.token="" --NotebookApp.disable_check_xsrf=True'

NOTE! This will disable Jupyter Notebook's token security. The option for container-user assures that the notebook will not run as a privileged user. You can set --NotebookApp.token to a string if you want to add a minimal layer of security.

BAM! Visit your Docker host on port 8000 and you have a working tmpnb setup. The -v /var/run/docker.sock:/docker.sock bit causes the orchestrator container to mount the docker client, which allows the orchestrator container to spawn docker containers on the host (see this article for more information).

If you are running docker using docker-machine, as is now the standard, get the IP address of your Docker host by running docker-machine ls. If you are using boot2docker, then you can find your docker host's ip address by running the following command in your console: boot2docker ip

If it didn't come up, try running docker ps -a and docker logs tmpnb to help diagnose issues.

Alternatively, you can choose to setup a docker-compose.yml file:

httpproxy:
  image: jupyter/configurable-http-proxy
  environment:
    CONFIGPROXY_AUTH_TOKEN: 716238957362948752139417234
  container_name:  tmpnb-proxy
  net: "host"
  command: --default-target http://127.0.0.1:9999
  ports:
    - 8000:8000

tmpnb_orchestrate:
  image: jupyter/tmpnb
  net: "host"
  container_name: tmpnb_orchestrate
  environment:
    CONFIGPROXY_AUTH_TOKEN: 716238957362948752139417234
  volumes:
    - /var/run/docker.sock:/docker.sock
  command: python orchestrate.py --command='jupyter notebook --no-browser --port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} --NotebookApp.port_retries=0 --NotebookApp.token="" --NotebookApp.disable_check_xsrf=True'

Then, you can launch the container with docker-compose up, no building is required since they pull directly from images.

Advanced configuration

If you need to set the docker-version or other options, they can be passed to jupyter/tmpnb directly:

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN -v /var/run/docker.sock:/docker.sock jupyter/tmpnb python orchestrate.py --cull-timeout=60 --docker-version="1.13" --command="jupyter notebook --NotebookApp.base_url={base_path} --ip=0.0.0.0 --port {port}"

Note that if you do not pass a value to docker-version, tmpnb will automatically use the Docker API version provided by the server.

The tmpnb server has two APIs: a public one that receives HTTP requests under the / proxy route and an administrative one available only on the private, localhost interface by default. You can configure the interfaces (--ip, --admin_ip) and ports (--port, --admin_port) of both APIs using command line arguments.

If you decide to expose the admin API on a public interface, you can protect it by specifying a secret token in the environment variable ADMIN_AUTH_TOKEN when starting the tmpnb container. Thereafter, all requests made to the admin API must include it in an HTTP header like so:

Authorization: token <admin secret token here>

Likewise, if you only want to allow programmatic access to your tmpnb cluster by select clients, you can specify a separate secret token in the environment variable API_AUTH_TOKEN when starting the tmpnb container. All requests made to the public API must include it in an HTTP header in the same manner as depicted for the admin token above. Note that when this token is set, only the /api/* resources of the tmpnb server are available. All human-facing paths are disabled.

If you want to see the resources available in both the admin and user APIs, look at the handler paths registered in the orchestrate.py file. You should consider both APIs to be unstable.

Launching with your own Docker images

tmpnb can run any Docker container provided by the --image option, so long as the --command option tells where the {base_path} and {port}. Those are literal strings, complete with curly braces that tmpnb will replace with an assigned base_path and port.

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
           -v /var/run/docker.sock:/docker.sock \
           jupyter/tmpnb python orchestrate.py --image='jupyter/demo' --command="jupyter notebook --NotebookApp.base_url={base_path} --ip=0.0.0.0 --port {port}"

Using jupyter/docker-stacks images

When using the latest jupyter/docker-stacks images with tmpnb, you can use the start-notebook.sh script or invoke the jupyter notebook command directly to run your notebook servers as user jovyan. Substitute your desired docker-stacks image name in the command below.

docker run -d \
    --net=host \
    -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
    -v /var/run/docker.sock:/docker.sock \
    jupyter/tmpnb \
    python orchestrate.py --image='jupyter/minimal-notebook' \
        --command='start-notebook.sh \
            "--NotebookApp.base_url={base_path} \
            --ip=0.0.0.0 \
            --port={port} \
            --NotebookApp.trust_xheaders=True"'

Options

Usage: orchestrate.py [OPTIONS]

Options:

  --help                           show this help information

tornado/log.py options:

  --log-file-max-size              max size of log files before rollover
                                   (default 100000000)
  --log-file-num-backups           number of log files to keep (default 10)
  --log-file-prefix=PATH           Path prefix for log files. Note that if you
                                   are running multiple tornado processes,
                                   log_file_prefix must be different for each
                                   of them (e.g. include the port number)
  --log-rotate-interval            The interval value of timed rotating
                                   (default 1)
  --log-rotate-mode                The mode of rotating files(time or size)
                                   (default size)
  --log-rotate-when                specify the type of TimedRotatingFileHandler
                                   interval other options:('S', 'M', 'H', 'D',
                                   'W0'-'W6') (default midnight)
  --log-to-stderr                  Send log output to stderr (colorized if
                                   possible). By default use stderr if
                                   --log_file_prefix is not set and no other
                                   logging is configured.
  --logging=debug|info|warning|error|none
                                   Set the Python log level. If 'none', tornado
                                   won't touch the logging configuration.
                                   (default info)

orchestrate.py options:

  --admin-ip                       ip for the admin server to listen on
                                   [default: 127.0.0.1] (default 127.0.0.1)
  --admin-port                     port for the admin server to listen on
                                   (default 10000)
  --allow-credentials              Sets the Access-Control-Allow-Credentials
                                   header.
  --allow-headers                  Sets the Access-Control-Allow-Headers
                                   header.
  --allow-methods                  Sets the Access-Control-Allow-Methods
                                   header.
  --allow-origin                   Set the Access-Control-Allow-Origin header.
                                   Use '*' to allow any origin to access.
  --assert-hostname                Verify hostname of Docker daemon. (default
                                   False)
  --command                        Command to run when booting the image. A
                                   placeholder for {base_path} should be
                                   provided. A placeholder for {port} and {ip}
                                   can be provided. (default jupyter notebook
                                   --no-browser --port {port} --ip=0.0.0.0
                                   --NotebookApp.base_url={base_path}
                                   --NotebookApp.port_retries=0)
  --container-ip                   Host IP address for containers to bind to.
                                   If host_network=True, the host IP address
                                   for notebook servers to bind to. (default
                                   127.0.0.1)
  --container-port                 Within container port for notebook servers
                                   to bind to. If host_network=True, the
                                   starting port assigned to notebook servers
                                   on the host. (default 8888)
  --container-user                 User to run container command as
  --cpu-quota                      Limit CPU quota, per container.
                                   Units are CPU-µs per 100ms, so 1
                                   CPU/container would be:
                                   --cpu-quota=100000
  --cpu-shares                     Limit CPU shares, per container
  --cull-max                       Maximum age of a container (s), regardless
                                   of activity.                  Default: 14400
                                   (4 hours)                  A container that
                                   has been running for this long will be
                                   culled,         even if it is not idle.
                                   (default 14400)
  --cull-period                    Interval (s) for culling idle containers.
                                   (default 600)
  --cull-timeout                   Timeout (s) for culling idle containers.
                                   (default 3600)
  --docker-version                 Version of the Docker API to use (default
                                   auto)
  --expose-headers                 Sets the Access-Control-Expose-Headers
                                   header.
  --extra-hosts                    Extra hosts for the containers, multiple
                                   hosts can be specified         by using a
                                   comma-delimited string, specified in the
                                   form hostname:IP (default [])
  --host-directories               Mount the specified directory as a data
                                   volume, multiple         directories can be
                                   specified by using a comma-delimited string,
                                   directory         path must provided in full
                                   (eg: /home/steve/data/:r), permissions
                                   default to         rw
  --host-network                   Attaches the containers to the host
                                   networking instead of the default docker
                                   bridge. Affects the semantics of
                                   container_port and container_ip. (default
                                   False)
  --image                          Docker container to spawn for new users.
                                   Must be on the system already (default
                                   jupyter/minimal-notebook)
  --ip                             ip for the main server to listen on
                                   [default: all interfaces]
  --max-age                        Sets the Access-Control-Max-Age header.
  --max-dock-workers               Maximum number of docker workers (default 2)
  --mem-limit                      Limit on Memory, per container (default
                                   512m)
  --pool-name                      Container name fragment used to identity
                                   containers that belong to this instance.
  --pool-size                      Capacity for containers on this system. Will
                                   be prelaunched at startup. (default 10)
  --port                           port for the main server to listen on
                                   (default 9999)
  --redirect-uri                   URI to redirect users to upon initial
                                   notebook launch (default /tree)
  --static-files                   Static files to extract from the initial
                                   container launch
  --user-length                    Length of the unique /user/:id path
                                   generated per container (default 12)

Development

WARNING The Makefile used in the commands below assume your containers can be deleted. Please work on an isolated machine and read the cleanup target in the Makefile prior to executing.

git clone https://github.com/jupyter/tmpnb.git
cd tmpnb

# Kick off the proxy and run the server.
# Runs on all interfaces on port 8000 by default.
# NOTE: stops and deletes all containers
make dev

Troubleshooting

If you are receiving 500 errors after changing the proxy port, make sure that you are using the correct internal port (proxy port+1 unless you specify it otherwise).

More Repositories

1

jupyter

Jupyter metapackage for installation, docs and chat
Python
14,886
star
2

notebook

Jupyter Interactive Notebook
Jupyter Notebook
11,528
star
3

docker-stacks

Ready-to-run Docker images containing Jupyter applications
Python
7,890
star
4

nbdime

Tools for diffing and merging of Jupyter notebooks.
TypeScript
2,649
star
5

nbviewer

nbconvert as a web service: Render Jupyter Notebooks as static web pages
Python
2,204
star
6

nbconvert

Jupyter Notebook Conversion
Python
1,707
star
7

nbgrader

A system for assigning and grading notebooks
Python
1,274
star
8

dashboards

[RETIRED] See Voilà as a supported replacement
Jupyter Notebook
984
star
9

colaboratory

[deprecated] Jupyter CoLaboratory, goto google colab now
JavaScript
740
star
10

jupyter-drive

Google drive for jupyter notebooks
TypeScript
418
star
11

qtconsole

Jupyter Qt Console
Python
407
star
12

jupyter_client

Jupyter protocol client APIs
Python
379
star
13

terminado

Terminals served by tornado websockets
Python
366
star
14

atom-notebook

[Deprecated] Jupyter Notebook, but inside Atom.
JavaScript
306
star
15

help

✨ Need some help or have some questions? Please visit our Discourse page.
291
star
16

nbformat

Reference implementation of the Jupyter Notebook format
Python
259
star
17

jupyter_console

Jupyter Terminal Console
Python
249
star
18

jupyter_core

Core Jupyter functionality
Python
195
star
19

docker-notebook

Docker containers for the IPython notebook (+SciPy Stack)
Shell
188
star
20

jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
Python
186
star
21

dashboards_server

[RETIRED] Server that runs and renders Jupyter notebooks as interactive dashboards
JavaScript
181
star
22

jupyter.github.io

Project Jupyter's home on the World Wide Web
HTML
177
star
23

nbconvert-examples

Examples that illustrate how nbconvert can be used
Jupyter Notebook
164
star
24

kernel_gateway_demos

Demos associated with the kernel gateway incubator project
Jupyter Notebook
152
star
25

nbclient

A client library for executing notebooks. Formally nbconvert's ExecutePreprocessor
Python
149
star
26

declarativewidgets

[RETIRED] Jupyter Declarative Widget Extension
HTML
120
star
27

enhancement-proposals

Enhancement proposals for the Jupyter Ecosystem
Python
115
star
28

papyri

Python
84
star
29

roadmap

Master roadmap for Project Jupyter
84
star
30

governance

The governance process and model for Project Jupyter
Python
82
star
31

design

Design related materials for Project Jupyter
HTML
80
star
32

dashboards_bundlers

[RETIRED] Converts a notebook to a dashboard and deploys it / downloads it
Python
79
star
33

docker-demo-images

Demo images for use in try.jupyter.org and tmpnb.org
Jupyter Notebook
75
star
34

scipy-advanced-tutorial

Advance Tutorial For SciPy
JavaScript
75
star
35

nbclassic

Jupyter Notebook as a Jupyter Server extension
JavaScript
74
star
36

nb2kg

Python
73
star
37

services

This repository is deprecated. It has been moved to https://github.com/jupyterlab/jupyterlab as a sub-package
TypeScript
70
star
38

accessibility

A repository for ongoing work around making Jupyter's software accessible and inclusive
Python
65
star
39

jupyter_kernel_test

A tool for testing Jupyter kernels
Python
62
star
40

jupyter-packaging

Tools to help build and install Jupyter Python packages
Python
62
star
41

nbmanager

View and stop running IPython notebook servers
Python
51
star
42

telemetry

Configurable event-logging for Jupyter applications and extensions.
Python
50
star
43

ngcm-tutorial

Materials for the IPython/Jupyter workshop at the NGCM Summer Academy, at Southampton University, Boldrewood campus.
Jupyter Notebook
46
star
44

jupyter-js-notebook

JupyterLab notebook
TypeScript
46
star
45

debugger

Research and explorations for an interactive debugger for Jupyter
41
star
46

echo_kernel

A simple example kernel for Jupyter
Python
39
star
47

ipython-py3k

**DO NOT USE THIS REPOSITORY AT ALL** This repo has been merged into the main IPython one that now contains Python 3 support. This is kept only as a reference to developers.
Python
34
star
48

jsplugins

JavaScript Plugins for the IPython Notebook
32
star
49

jupyterhub-2016-workshop

Materials for an online mini-workshop around JupyterHub use cases, held July 22nd, 2016
31
star
50

dashboards_setup

[RETIRED] Recipes for setting up components related to the incubating dashboards effort
Jupyter Notebook
28
star
51

testpath

Test utilities for Python code working with files and commands
Python
27
star
52

strata-sv-2015-tutorial

Strata Silicon Valley 2015 Tutorial
Python
24
star
53

jupyter-js-plugins

TypeScript
23
star
54

surveys

Surveys and datasets collected by Project Jupyter
Jupyter Notebook
23
star
55

jupyter-sphinx-theme

A Sphinx theme for Jupyter and IPython documentation
HTML
22
star
56

jvm-repr

API for converting JVM objects to representations by MIME type, for the Jupyter ecosystem.
Java
22
star
57

notebook-research

Research on the usage of Jupyter notebooks
Jupyter Notebook
20
star
58

security

19
star
59

tutorial-dashboards-declarativewidgets

Materials for the PyData Carolinas 2016 tutorial, Turning Jupyter Notebooks into Data Applications
Jupyter Notebook
19
star
60

tmpnb-deploy

Deploying tmpnb nodes
Python
18
star
61

jupyterlab_json

This repository is deprecated. The extension has moved to https://github.com/jupyterlab/jupyter-renderers
JavaScript
16
star
62

kernels

Kernel testing and listing infrastructure
Python
16
star
63

mozfest15-training

Notebooks for Jupyter training session at Mozfest 2015
Jupyter Notebook
13
star
64

newsletter

A repo for collecting content for the Jupyter Newsletter
Jupyter Notebook
13
star
65

jupyterlab_geojson

This repository is deprecated. The extension has moved to https://github.com/jupyterlab/jupyter-renderers
JavaScript
13
star
66

tmpnb-redirector

Simple HTTP redirector for tmpnb nodes
Python
12
star
67

nature-demo

Materials for the November 2014 Nature Article
Jupyter Notebook
12
star
68

extension-builder

This repository is deprecated.
TypeScript
12
star
69

jupyter_events

Configurable event system for Jupyter applications and extensions.
Python
11
star
70

phosphor-notebook

Phosphor-based jupyter notebook
TypeScript
11
star
71

ipython-components

third-party javascript dependencies of IPython
JavaScript
11
star
72

try.jupyter.org

Try Jupyter!
HTML
10
star
73

jupyter-js-ui

TypeScript
10
star
74

jupyter-js-output-area

DEPRECATED: Javascript APIs for Jupyter output areas
TypeScript
10
star
75

cookiecutter-docker-stacks

Cookiecutter for community-maintained Jupyter Docker images
Python
10
star
76

ideas

A place for the Jupyter community to connect on ideas
9
star
77

kernel_gateway_bundlers

Converts a notebook to a kernel gateway microservice bundle for download
Python
8
star
78

jupyter_markdown

Documentation and tests related to Jupyter's Markdown syntax
Jupyter Notebook
8
star
79

try-jupyter

A JupyterLite deployment to try JupyterLab, Jupyter Notebook and IPython in the browser
Jupyter Notebook
8
star
80

talks

A collection of talks about Jupyter and IPython projects
Jupyter Notebook
8
star
81

jvm-magics

A plugin system for magic function implementations across JVM kernels.
Java
7
star
82

cdn.jupyter.org

Assets and layout for cdn.jupyter.org
Python
7
star
83

jupyter-js-utils

JavaScript utilities for the Jupyter frontend
TypeScript
6
star
84

jupyter_logger

Allows you to log Jupyter notebook user events anonymously.
TypeScript
6
star
85

jupyter-js-filebrowser

DEPRECATED: This code was copied into https://github.com/jupyter/jupyter-js-ui
TypeScript
5
star
86

notebook_shim

A shim layer for notebook traits and config
Python
5
star
87

jupyter-sprints

Resources for running a sprint
HTML
5
star
88

nbcache

Notebook Caching layer in Docker
5
star
89

docs-team-compass

Documentation Work Group Discussions
HTML
5
star
90

jupyter-js-input-area

DEPRECATED: Javascript APIs for Jupyter input areas
TypeScript
5
star
91

sphinxcontrib_github_alt

Github roles for Sphinx docs
Python
5
star
92

jupyterhub-carina

[RETIRED] JupyterHub integration with Carina
Python
5
star
93

win-tornado-terminals

Windows terminal backend for tornado
Python
5
star
94

jupyterlab-fasta

DEPRECATED: Moved to https://github.com/jupyterlab/jupyter-renderers. A JupyterLab Fasta viewer
TypeScript
5
star
95

spreadsheet

A spreadsheet component for phosphor
JavaScript
5
star
96

jupyter-js-editor

DEPRECATED: This code was copied into https://github.com/jupyter/jupyter-js-notebook
TypeScript
4
star
97

jupyter-communitycalls

📣 Resources for planning and hosting the Jupyter Community Calls
4
star
98

distinguished-contributors

Jupyter Distinguished Contributors
4
star
99

project-mgt

4
star
100

showcase

[RETIRED] A spot to try demos of one or more incubating Jupyter projects in Binder
Makefile
4
star