At PyCon 2015, iPython (Jupyter) Notebook is indispensable for various people! So I thought I'd install it for the time being, but I didn't have enough Japanese information that I tried Jupyter Saba with Docker, so I'll share the work record.
Since Debian 8 (Jassie) is the mother ship,
$ sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
bash:/etc/apt/sources.list.d/docker.list
# Debian Jessie
deb https://apt.dockerproject.org/repo debian-jessie main
$ sudo apt-get update
$ sudo apt-get install docker-engine
$ sudo usermod -a -G docker yi01
There are some traps here.
First, it's on Docker Hub
There is no implementation around authentication, so you need to create jupyterhub_config.py
and define the authentication method etc. using the -v
option of docker.
However, it is troublesome to make various things from scratch, so I will use example using OAuth on GitHub prepared by jupyter.
$ git clone https://github.com/jupyter/oauthenticator.git
$ cd oauthenticator
Now, edit the userlist according to the README.
GitHub user settings
diff --git a/example/addusers.sh b/example/addusers.sh
index eb2d86b..cedd272 100644
--- a/example/addusers.sh
+++ b/example/addusers.sh
@@ -7,6 +7,6 @@ for line in `cat userlist`; do
user=`echo $line | cut -f 1 -d' '`
echo "adding user $user"
useradd -m -s /bin/bash $user
- cp -r /srv/ipython/examples /home/$user/examples
- chown -R $user /home/$user/examples
+# cp -r /srv/ipython/examples /home/$user/examples
+# chown -R $user /home/$user/examples
done
diff --git a/example/userlist b/example/userlist
index e69de29..d8f3556 100644
--- a/example/userlist
+++ b/example/userlist
@@ -0,0 +1 @@
+YusukeIwaki admin
As a caveat, if you just edit the userlist, with docker build
cp: cannot stat ‘/srv/ipython/examples’: No such file or directory
chown: cannot access ‘/home/YusukeIwaki/examples’: No such file or directory
I get an error like this and it gets moss, so I will edit the shell script a little. After editing,
$ cd example
$ docker build -t jupyter/oauthenticator .
So, if you get a Succeed-like log,
Verification
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
jupyter/oauthenticator latest 209358b449b6 24 seconds ago 934.9 MB
jupyter/jupyterhub latest fd5445f17a96 5 days ago 934.8 MB
Set like this. Please read the callback host name and port number as appropriate. After registering the OAuth authentication information on the GitHub site side, enter the Client ID and secret obtained there.
secret
diff --git a/example/env b/example/env
index 9f32b5c..7a921da 100644
--- a/example/env
+++ b/example/env
@@ -1,5 +1,5 @@
# add your github oauth config to this file,
# and run the container with `docker run -it -p 9000:8000 --env-file=env jupyter/oauthenticator`
-GITHUB_CLIENT_ID=
-GITHUB_CLIENT_SECRET=
-OAUTH_CALLBACK_URL=
+GITHUB_CLIENT_ID=21d***********e7a3
+GITHUB_CLIENT_SECRET=2ea1f***********************e9da7
+OAUTH_CALLBACK_URL=http://localhost:8001/hub/oauth_callback
Set it like this.
$ docker run -it -p 8001:8000 --env-file=env jupyter/oauthenticator
So, when you access it from a browser ...
Kita━━━━ (゜ ∀ ゜) ━━━━ !!
Recommended Posts