aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Proell <stefan.proell@cropster.com>2018-02-13 09:36:34 +0000
committerStefan Proell <stefan.proell@cropster.com>2018-02-13 09:36:34 +0000
commit68964bf8f63280f0cb7355108ac1f5e1a62455c9 (patch)
tree8a1032673d7ea0ed6a4c573df31811b260c73a4e
downloadjupyter-notebook-docker-compose-68964bf8f63280f0cb7355108ac1f5e1a62455c9.tar.gz
jupyter-notebook-docker-compose-68964bf8f63280f0cb7355108ac1f5e1a62455c9.zip
Adds a docker--compose file and an environment file for launching Jupyter Notebooks
-rw-r--r--.env28
-rw-r--r--README.md72
-rw-r--r--docker-compose.yml15
-rwxr-xr-xgenerate_token.py17
-rw-r--r--jupyter.pem51
5 files changed, 183 insertions, 0 deletions
diff --git a/.env b/.env
new file mode 100644
index 0000000..9de96de
--- /dev/null
+++ b/.env
@@ -0,0 +1,28 @@
+# Define a local data directory
+# Set permissions for the container:
+# sudo chown -R 1000 ${LOCAL_WORKING_DIR}
+
+LOCAL_WORKING_DIR=/data/jupyter/notebooks
+
+# Generate an access token like this
+# import IPython as IPython
+# hash = IPython.lib.passwd("S-E-C-R-E-T")
+# print(hash)
+# You can use the script generate_token.py
+
+ACCESS_TOKEN=sha1:d4c78fe19cb5:0c8f830971d52da9d74b9985a8b87a2b80fc6e6a
+
+# Host port
+PORT=8888
+
+# Provide data sets
+LOCAL_DATASETS=/data/jupyter/datasets
+
+# Provide local modules
+LOCAL_MODULES=/home/git/python_modules
+
+# SSL
+# Generate cert like this:
+# openssl req -x509 -nodes -newkey rsa:2048 -keyout jupyter.pem -out jupyter.pem
+# Copy the jupyter.pem file into the location below.
+LOCAL_SSL_CERTS=/opt/ssl-certs/jupyter
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..09c333e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+# Jupyter with Docker Compose
+
+This repository contains a simple docker-compose definition for launching the popular Jupyter Data Science Notebook.
+You can define a password with the script ```generate_token.py -p S-E-C-R-E-T``` and generate SSL certificates as described below.
+
+## Control the container:
+
+* ```docker-compose up``` mounts the directory and starts the container
+* ```docker-compose down``` destroys the container
+
+## The compose file: docker-compose.yml
+
+```bash
+version: '3'
+services:
+ datascience-notebook:
+ image: jupyter/datascience-notebook
+ volumes:
+ - ${LOCAL_WORKING_DIR}:/home/jovyan/work
+ - ${LOCAL_DATASETS}:/home/jovyan/work/datasets
+ - ${LOCAL_MODULES}:/home/jovyan/work/modules
+ - ${LOCAL_SSL_CERTS}:/etc/ssl/notebook
+ ports:
+ - ${PORT}:8888
+ container_name: jupyter_notebook
+ command: "start-notebook.sh \
+ --NotebookApp.password=${ACCESS_TOKEN} \
+ --NotebookApp.certfile=/etc/ssl/notebook/jupyter.pem"
+```
+
+
+## The environment file .env
+
+```bash
+# Define a local data directory
+# Set permissions for the container:
+# sudo chown -R 1000 ${LOCAL_WORKING_DIR}
+
+LOCAL_WORKING_DIR=/data/jupyter/notebooks
+
+# Generate an access token like this
+# import IPython as IPython
+# hash = IPython.lib.passwd("S-E-C-R-E-T")
+# print(hash)
+# You can use the script generate_token.py
+
+ACCESS_TOKEN=sha1:d4c78fe19cb5:0c8f830971d52da9d74b9985a8b87a2b80fc6e6a
+
+# Host port
+PORT=8888
+
+# Provide data sets
+LOCAL_DATASETS=/data/jupyter/datasets
+
+# Provide local modules
+LOCAL_MODULES=/home/git/python_modules
+
+# SSL
+# Generate cert like this:
+# openssl req -x509 -nodes -newkey rsa:2048 -keyout jupyter.pem -out jupyter.pem
+# Copy the jupyter.pem file into the location below.
+LOCAL_SSL_CERTS=/opt/ssl-certs/jupyter
+```
+
+
+
+# Version Conflicts
+
+Make sure to have the latest versions installed. You can use the Notebook Browser interface.
+```python
+pip install -U jupyter
+```
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..8856451
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,15 @@
+version: '3'
+services:
+ datascience-notebook:
+ image: jupyter/datascience-notebook
+ volumes:
+ - ${LOCAL_WORKING_DIR}:/home/jovyan/work
+ - ${LOCAL_DATASETS}:/home/jovyan/work/datasets
+ - ${LOCAL_MODULES}:/home/jovyan/work/modules
+ - ${LOCAL_SSL_CERTS}:/etc/ssl/notebook
+ ports:
+ - ${PORT}:8888
+ container_name: jupyter_notebook
+ command: "start-notebook.sh \
+ --NotebookApp.password=${ACCESS_TOKEN} \
+ --NotebookApp.certfile=/etc/ssl/notebook/jupyter.pem"
diff --git a/generate_token.py b/generate_token.py
new file mode 100755
index 0000000..54e3c39
--- /dev/null
+++ b/generate_token.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env sh
+import IPython as IPython
+
+if __name__ == "__main__":
+ print("Generate a access token")
+ from argparse import ArgumentParser
+ parser = ArgumentParser()
+ parser.add_argument("-p",
+ "--password",
+ dest="password",
+ help="The password you want to use for authentication.",
+ required=True)
+ args = parser.parse_args()
+
+ print("\nCopy this line into the .env file:\n")
+ hash = IPython.lib.passwd(args.password)
+ print("ACCESS_TOKEN=" + hash)
diff --git a/jupyter.pem b/jupyter.pem
new file mode 100644
index 0000000..1457bbb
--- /dev/null
+++ b/jupyter.pem
@@ -0,0 +1,51 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDtGlWjn9Sw2aV0
+32H7le8Ra2cQRx5cS/m5R8HL0Tl/JlYwLBXNZcsUmnqOKCxJFilkBcj4BIAic5ZR
+b1AyTPn1RERf6SbFLZGBUnYcLQDL6Z6qEILe0H5G30yFjdvjUVnhYPUsWW6H1tUF
+EhtuMduj2o+2YUaiE6UQAD5EfX09jzGcwNx/Hj1XXvpRSfDBQWlWxkKOm6TqGoXH
+FBAIGAH1gKehotGDd+YluOFp9qk8G2e2Tvpg7JQfaSoIT1ViHwg+0XSQVoVRNqWK
+XQ+MD+dCcwbcL7kAbnLW1x1a4ym9as5t/iDUjVldh70coJ9uaa1CHklAZzheH6Xc
+up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