How to add a notebook to a dockerspawner configuration?

594 views
Skip to first unread message

Tiago Cunha

unread,
Mar 12, 2016, 6:45:33 PM3/12/16
to Project Jupyter
Hi guys, I managed to put my jupyterhub to work. But now I don't now how to add a notebook to image in order to when the users log in the system they can see my code.

The steps that I performed were those: I installed jupyterhub( with pip, I didn't clone the repository), then I install dockerspawner and I installed the OAuthenticator.

My server is working, I am able to authenticate with github, but when I start my server it is empty, can you guys help to add the notebooks? Just to let you guys know, I am a beginner with docker and jupyterhub.

MinRK

unread,
Mar 13, 2016, 4:13:46 PM3/13/16
to jup...@googlegroups.com

You can build your own image, and add files there:

FROM jupyter/singleuser
ADD mynotebook.ipynb /path/to/mynotebook.ipynb

Then build your image:

docker build -t myimage .

Then tell DockerSpawner to use your image:

# juptyerhub_config.py
c.DockerSpawner.container_image = 'myimage'

-MinRK


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/cba00416-9ea3-4fba-8073-42190387277f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tiago Cunha

unread,
Mar 14, 2016, 12:57:38 AM3/14/16
to Project Jupyter
Hey MinRK, thank you so much for your answer. Now I am able to build my own image and I added the image to my jupyter_config.py, but nothing changed. I edited the config file inside the folder oauth, is that right? Since I used pip to install jupyter, this is the only config file that I am aware.

Tiago Cunha

unread,
Mar 14, 2016, 1:54:29 AM3/14/16
to Project Jupyter
This is the content of my Dockerfile:

FROM jupyter/singleuser

RUN pip install gensim

ADD causal-inference.ipynb .

Should I put something else?

MinRK

unread,
Mar 14, 2016, 7:58:15 AM3/14/16
to jup...@googlegroups.com
jupyterhub_config.py will be in your working directory when you start jupyterhub. It's whatever file you have that says `c.JupyterHub.spawner_class = ...DockerSpawner`.

-MinRK

Tiago Cunha

unread,
Mar 14, 2016, 3:07:34 PM3/14/16
to Project Jupyter
Man, thank you so much for your help, but unfortunately it didn't work. Other thing that I didn't figured out yet is how to generate the file.key and file.cert to run with ssl.

Tiago Cunha

unread,
Mar 15, 2016, 3:43:41 AM3/15/16
to Project Jupyter
Hey MinRK, sorry for bother you again. I run my run.sh and connected with a user, than a run docker ps and saw that the image that is been used in my container is the none, I tried to put in my jupyterhub_conf.py the line c.DockerSpawner.container_image = "myimage", but it didn't work change the image used in the container.


Em segunda-feira, 14 de março de 2016 14:58:15 UTC+3, Min RK escreveu:

MinRK

unread,
Mar 15, 2016, 5:15:54 AM3/15/16
to jup...@googlegroups.com
Since DockerSpawner re-uses containers if they already exist, you may need to do some manual cleanup when you change configuration and relaunch the Hub. Try removing any existing containers after you change the image in configuration, to make sure it's starting from a clean slate.

-MinRK

Tiago Cunha

unread,
Mar 15, 2016, 5:47:06 AM3/15/16
to Project Jupyter
After remove all containers now I get the following error:

[I 2016-03-15 09:41:22.153 JupyterHub app:558] Loading cookie_secret from /home/ubuntu/dockerspawner/examples/oauth/jupyterhub_cookie_secret
[W 2016-03-15 09:41:22.176 JupyterHub app:292]
Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.

[I 2016-03-15 09:41:22.202 JupyterHub dockerspawner:333] Container 'jupyter-tocunha' is gone
[W 2016-03-15 09:41:22.202 JupyterHub dockerspawner:304] container not found
[I 2016-03-15 09:41:22.219 JupyterHub dockerspawner:333] Container 'jupyter-ingmarweber' is gone
[W 2016-03-15 09:41:22.219 JupyterHub dockerspawner:304] container not found
[I 2016-03-15 09:41:22.225 JupyterHub dockerspawner:333] Container 'jupyter-test-jupyter' is gone
[W 2016-03-15 09:41:22.225 JupyterHub dockerspawner:304] container not found
[E 2016-03-15 09:41:22.231 JupyterHub app:1109] Failed to bind hub to http://172.31.27.200:8081/hub/
[E 2016-03-15 09:41:22.231 JupyterHub app:1177]
Traceback (most recent call last):
File "/home/ubuntu/dockerspawner/examples/oauth/src/jupyterhub/jupyterhub/app.py", line 1175, in launch_instance_async
yield self.start()
File "/home/ubuntu/dockerspawner/examples/oauth/src/jupyterhub/jupyterhub/app.py", line 1107, in start
self.http_server.listen(self.hub_port, address=self.hub_ip)
File "/usr/local/lib/python3.4/dist-packages/tornado/tcpserver.py", line 126, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python3.4/dist-packages/tornado/netutil.py", line 196, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 98] Address already in use

Tiago Cunha

unread,
Mar 15, 2016, 6:10:10 AM3/15/16
to Project Jupyter
I included c.DockerSpawner.hub_ip_connect = '10.65.197.128' in my jupyter_conf.py and I am not getting the error anymore, but now when I click in start server it doesn't connect and I get the following error:

10:07:54.916 - error: [ConfigProxy] Proxy error:  code=ECONNRESET
10:07:54.921 - error: [ConfigProxy] 503 GET /user/test-jupyter/tree

Tiago Cunha

unread,
Mar 15, 2016, 6:55:00 AM3/15/16
to Project Jupyter
I removed c.DockerSpawner.hub_ip_connect = '10.65.197.128' and now is working:D

But interesting after access the notebook I can't download it.
Reply all
Reply to author
Forward
0 new messages