@@ -52,137 +52,42 @@ Key components of this reference deployment are:
52
52
* ** Persistence of user notebook directories** : Persists user notebook
53
53
directories in Docker volumes on the host.
54
54
55
- <!--  -->
56
-
57
55
58
56
## Prerequisites
59
57
60
58
### Docker
61
59
62
- This deployment uses Docker, via [ Docker Compose] ( https://docs.docker.com/compose/overview/ ) , for all the things.
63
- [ Docker Engine] ( https://docs.docker.com/engine ) 1.12.0 or higher is
64
- required.
60
+ This deployment uses Docker, via [ Docker Compose] ( https://docs.docker.com/compose/ ) , for all the things.
65
61
66
62
1 . Use [ Docker's installation instructions] ( https://docs.docker.com/engine/installation/ )
67
63
to set up Docker for your environment.
68
64
69
- 2 . To verify your docker installation, whether running docker as a local
70
- installation or using [ docker-machine] ( ./docs/docker-machine.md ) ,
71
- enter these commands:
72
-
73
- ``` bash
74
- docker version
75
- docker ps
76
- ```
77
-
78
- ### HTTPS and SSL/TLS certificate
79
-
80
- This deployment configures JupyterHub to use HTTPS. You must provide a
81
- certificate and key file in the JupyterHub configuration. To configure:
82
-
83
- 1 . Obtain the domain name that you wish to use for JupyterHub, for
84
- example, ` myfavoritesite.com ` or ` jupiterplanet.org ` .
85
-
86
- 1 . If you do not have an existing certificate and key, you can:
87
-
88
- - obtain one from [ Let's Encrypt] ( https://letsencrypt.org ) using
89
- the [ certbot] ( https://certbot.eff.org ) client,
90
- - use the helper script in this repo's [ letsencrypt example] ( examples/letsencrypt/README.md ) , or
91
- - [ create a self-signed certificate] ( https://jupyter-notebook.readthedocs.org/en/latest/public_server.html#using-ssl-for-encrypted-communication ) .
92
-
93
- 1 . Copy the certificate and key files to a
94
- directory named ` secrets ` in this repository's root directory. These will be
95
- added to the JupyterHub Docker image at build time. For example, create a
96
- ` secrets ` directory in the root of this repo and copy the certificate and
97
- key files (` jupyterhub.crt ` and ` jupyterhub.key ` ) to this directory:
98
-
99
- ``` bash
100
- mkdir -p secrets
101
- cp jupyterhub.crt jupyterhub.key secrets/
102
- ```
103
-
104
65
105
66
## Authenticator setup
106
67
107
- This deployment uses GitHub OAuth to authenticate users.
108
-
109
- It requires that you create and register a [ GitHub OAuth application] ( https://github.com/settings/applications/new )
110
- by filling out a form on the GitHub site:
111
-
112
- ![ GitHub OAuth application form] ( docs/oauth-form.png )
113
-
114
- In this form, you will specify the OAuth application's callback URL in
115
- this format: ` https://<myhost.mydomain>/hub/oauth_callback ` .
116
-
117
- After you submit the GitHub form, GitHub registers your OAuth application and
118
- assigns a unique Client ID and Client Secret. The Client Secret should be
119
- kept private.
120
-
121
- At JupyterHub's runtime, you must pass the GitHub OAuth Client ID, Client
122
- Secret and OAuth callback url. You can do this by either:
123
-
124
- - setting the ` GITHUB_CLIENT_ID ` , ` GITHUB_CLIENT_SECRET ` , and
125
- ` OAUTH_CALLBACK_URL ` environment variables when you run the
126
- JupyterHub container, or
127
- - add them to an ` oauth.env ` file in the ` secrets ` directory of this repository.
128
- You may need to create both the ` secrets ` directory and the ` oauth.env ` file.
129
- For example, add the following lines in the ` oauth.env ` file:
130
-
131
- ` oauth.env ` file
132
- ```
133
- GITHUB_CLIENT_ID=<github_client_id>
134
- GITHUB_CLIENT_SECRET=<github_client_secret>
135
- OAUTH_CALLBACK_URL=https://<myhost.mydomain>/hub/oauth_callback
136
- ```
137
-
138
- ** Note:** The ` oauth.env ` file is a special file that Docker Compose uses
139
- to lookup environment variables. If you choose to place the GitHub
140
- OAuth application settings in this file, you should make sure that the
141
- file remains private (be careful to not commit the ` oauth.env ` file with
142
- these secrets to source control).
68
+ This deployment uses [ JupyterHub Native Authenticator] ( https://native-authenticator.readthedocs.io/en/latest/ ) to authenticate users.
143
69
70
+ 1 . An single ` admin ` user will be enabled be default.
144
71
145
72
## Build the JupyterHub Docker image
146
73
147
- Finish configuring JupyterHub and then build the hub's Docker image. (We'll
148
- build the Jupyter Notebook image in the next section.)
149
-
150
- 1 . Configure ` userlist ` : Create a ` userlist ` file of authorized JupyterHub
151
- users. The list should contain GitHub usernames, and this file should
152
- designate at least one ` admin ` user. For instance, the example file below
153
- contains three users, ` jtyberg ` , ` jenny ` , and ` guido ` , and one designated
154
- administrator, ` jtyberg ` :
155
-
156
- ` userlist ` file
157
- ```
158
- jtyberg admin
159
- jenny
160
- guido
161
- ```
162
-
163
- The admin user will have the ability to add more users through JupyterHub's
164
- admin console.
165
-
166
74
1 . Use [ docker-compose] ( https://docs.docker.com/compose/reference/ ) to build
167
75
the JupyterHub Docker image on the active Docker machine host by running
168
76
the ` make build ` command:
169
77
170
78
``` bash
171
- make build
79
+ docker-compose build
172
80
```
173
81
174
82
175
- ## Spawner: Prepare the Jupyter Notebook Image
83
+ ## Customisation: Jupyter Notebook Image
176
84
177
85
You can configure JupyterHub to spawn Notebook servers from any Docker image, as
178
86
long as the image's ` ENTRYPOINT ` and/or ` CMD ` starts a single-user instance of
179
87
Jupyter Notebook server that is compatible with JupyterHub.
180
88
181
89
To specify which Notebook image to spawn for users, you set the value of the
182
90
` DOCKER_NOTEBOOK_IMAGE ` environment variable to the desired container image.
183
- You can set this variable in the ` .env ` file, or alternatively, you can
184
- override the value in this file by setting ` DOCKER_NOTEBOOK_IMAGE ` in the
185
- environment where you launch JupyterHub.
186
91
187
92
Whether you build a custom Notebook image or pull an image from a public or
188
93
private Docker registry, the image must reside on the host.
@@ -193,20 +98,16 @@ JupyterHub may timeout if the image being pulled is large, so it is better to
193
98
pull the image to the host before running JupyterHub.
194
99
195
100
This deployment defaults to the
196
- [ jupyter/scipy-notebook] ( https://hub.docker.com/r/jupyter/scipy-notebook/ )
197
- Notebook image, which is built from the ` scipy-notebook `
198
- [ Docker stacks] ( https://github.com/jupyter/docker-stacks ) . (Note that the Docker
199
- stacks ` *-notebook ` images tagged ` 2d878db5cbff ` include the
200
- ` start-singleuser.sh ` script required to start a single-user instance of the
201
- Notebook server that is compatible with JupyterHub).
101
+ [ jupyter/minimal-notebook] ( https://hub.docker.com/r/jupyter/minimal-notebook/ )
102
+ Notebook image, which is built from the ` minimal-notebook `
103
+ [ Docker stacks] ( https://github.com/jupyter/docker-stacks ) .
202
104
203
105
You can pull the image using the following command:
204
106
205
107
``` bash
206
- make notebook_image
108
+ docker pull jupyter/minimal-notebook
207
109
```
208
110
209
-
210
111
## Run JupyterHub
211
112
212
113
Run the JupyterHub container on the host.
@@ -219,9 +120,8 @@ docker-compose up -d
219
120
220
121
Once the container is running, you should be able to access the JupyterHub console at
221
122
222
- ** file**
223
123
```
224
- https ://myhost.mydomain
124
+ http ://localhost:8000
225
125
```
226
126
227
127
To bring down the JupyterHub container:
@@ -232,33 +132,6 @@ docker-compose down
232
132
233
133
---
234
134
235
- ## Behind the scenes
236
-
237
- ` make build ` does a few things behind the scenes, to set up the environment for JupyterHub:
238
-
239
- ### Create a JupyterHub Data Volume
240
-
241
- Create a Docker volume to persist JupyterHub data. This volume will reside on the host machine. Using a volume allows user lists, cookies, etc., to persist across JupyterHub container restarts.
242
-
243
- ``` bash
244
- docker volume create --name jupyterhub-data
245
- ```
246
-
247
- ### Create a Docker Network
248
-
249
- Create a Docker network for inter-container communication. The benefits of using a Docker network are:
250
-
251
- * container isolation - only the containers on the network can access one another
252
- * name resolution - Docker daemon runs an embedded DNS server to provide automatic service discovery for containers connected to user-defined networks. This allows us to access containers on the same network by name.
253
-
254
- Here we create a Docker network named ` jupyterhub-network ` . Later, we will configure the JupyterHub and single-user Jupyter Notebook containers to run attached to this network.
255
-
256
- ``` bash
257
- docker network create jupyterhub-network
258
- ```
259
-
260
- ---
261
-
262
135
## FAQ
263
136
264
137
### How can I view the logs for JupyterHub or users' Notebook servers?
@@ -281,28 +154,7 @@ variable:
281
154
282
155
``` python
283
156
# DockerSpawner setting in jupyterhub_config.py
284
- c.DockerSpawner.container_image = os.environ[' DOCKER_NOTEBOOK_IMAGE' ]
285
- ```
286
-
287
- By default, the` DOCKER_NOTEBOOK_IMAGE ` environment variable is set in the
288
- ` .env ` file.
289
-
290
- ** file**
291
- ```
292
- # Setting in the .env file
293
- DOCKER_NOTEBOOK_IMAGE=jupyter/scipy-notebook:2d878db5cbff
294
- ```
295
-
296
- To use a different notebook server image, you can either change the desired
297
- container image value in the ` .env ` file, or you can override it
298
- by setting the ` DOCKER_NOTEBOOK_IMAGE ` variable to a different Notebook
299
- image in the environment where you launch JupyterHub. For example, the
300
- following setting would be used to spawn single-user ` pyspark ` notebook servers:
301
-
302
- ``` bash
303
- export DOCKER_NOTEBOOK_IMAGE=jupyterhub/pyspark-notebook:2d878db5cbff
304
-
305
- docker-compose up -d
157
+ c.DockerSpawner.image = os.environ[' DOCKER_NOTEBOOK_IMAGE' ]
306
158
```
307
159
308
160
### If I change the name of the Notebook server image to spawn, do I need to restart JupyterHub?
0 commit comments