You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**[Build the JupyterHub Docker image](#build-the-jupyterhub-docker-image)** |
5
+
**[Spawner: Prepare the Jupyter Notebook Image](#spawner-prepare-the-jupyter-notebook-image)** |
6
+
**[Run JupyterHub](#run-jupyterhub)** |
7
+
**[Behind the scenes](#behind-the-scenes)** |
8
+
**[FAQ](#faq)**
9
+
1
10
# jupyterhub-deploy-docker
2
11
3
-
This repository provides a reference deployment of [JupyterHub](https://github.com/jupyter/jupyterhub), a multi-user [Jupyter Notebook](http://jupyter.org/) environment, on a **single host** using [Docker](https://docs.docker.com).
12
+
**jupyterhub-deploy-docker** provides a reference
13
+
deployment of [JupyterHub](https://github.com/jupyter/jupyterhub), a
14
+
multi-user [Jupyter Notebook](http://jupyter.org/) environment, on a
15
+
**single host** using [Docker](https://docs.docker.com).
4
16
5
-
This deployment:
17
+
Possible **use cases** include:
6
18
7
-
* Runs the [JupyterHub components](https://jupyterhub.readthedocs.org/en/latest/getting-started.html#overview) in a Docker container on the host
8
-
* Uses [DockerSpawner](https://github.com/jupyter/dockerspawner) to spawn single-user Jupyter Notebook servers in separate Docker containers on the same host
9
-
* Persists JupyterHub data in a Docker volume on the host
10
-
* Persists user notebook directories in Docker volumes on the host
11
-
* Uses [OAuthenticator](https://github.com/jupyter/oauthenticator) and [GitHub OAuth](https://developer.github.com/v3/oauth/) to authenticate users
19
+
* Creating a JupyterHub demo environment that you can spin up relatively
20
+
quickly.
21
+
* Providing a multi-user Jupyter Notebook environment for small classes,
22
+
teams, or departments.
12
23
13
-

24
+
**Disclaimer:** This deployment is **NOT** intended for a production
25
+
environment.
26
+
27
+
28
+
## Technical Overview
29
+
30
+
Key components of this reference deployment are:
31
+
32
+
***Host**: Runs the [JupyterHub components](https://jupyterhub.readthedocs.org/en/latest/getting-started.html#overview)
In this form, you will specify the OAuth application's callback URL in
109
+
this format: `https://<myhost.mydomain>/hub/oauth_callback`.
67
110
68
-
**Note:** The `.env` file is a special file that Docker Compose uses to lookup environment variables.
69
-
If you choose to place the GitHub secrets in this file,
70
-
you should ensure that this file remains private
71
-
(e.g., do not commit the secrets to source control).
111
+
After you submit the GitHub form, GitHub registers your OAuth application and
112
+
assigns a unique Client ID and Client Secret. The Client Secret should be
113
+
kept private.
72
114
73
-
## Build the JupyterHub Docker image
115
+
At JupyterHub's runtime, you must pass the GitHub OAuth Client ID, Client
116
+
Secret and OAuth callback url. You can do this by either:
74
117
75
-
Configure JupyterHub and build it into a Docker image.
118
+
- setting the `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET`, and
119
+
`OAUTH_CALLBACK_URL` environment variables when you run the
120
+
JupyterHub container, or
121
+
- add them to the `.env` file in the root directory of this repository.
122
+
For example, update the following lines in the `.env` file:
76
123
77
-
1. Copy the TLS certificate chain and key files for the JupyterHub server to a directory named `secrets` within this repository directory. These will be added to the JupyterHub Docker image at build time. If you do not have a certificate chain and key, you can either [create self-signed versions](https://jupyter-notebook.readthedocs.org/en/latest/public_server.html#using-ssl-for-encrypted-communication), or obtain real ones from [Let's Encrypt](https://letsencrypt.org) (see the [letsencrypt example](examples/letsencrypt/README.md) for instructions).
**Note:** The `.env` file is a special file that Docker Compose uses
132
+
to lookup environment variables. If you choose to place the GitHub
133
+
OAuth application settings in this file, you should make sure that the
134
+
file remains private (be careful to not commit the `.env` file with
135
+
these secrets to source control).
83
136
84
-
1. Create a `userlist` file with a list of authorized users. At a minimum, this file should contain a single admin user. The username should be a GitHub username. For example:
85
137
138
+
## Build the JupyterHub Docker image
139
+
140
+
Finish configuring JupyterHub and then build the hub's Docker image. (We'll
141
+
build the Jupyter Notebook image in the next section.)
142
+
143
+
1. Configure `userlist`: Create a `userlist` file of authorized JupyterHub
144
+
users. The list should contain GitHub usernames, and this file should
145
+
designate at least one `admin` user. For instance, the example file below
146
+
contains three users, `jtyberg`, `jenny`, and `guido`, and one designated
147
+
administrator, `jtyberg`:
148
+
149
+
`userlist` file
86
150
```
87
151
jtyberg admin
152
+
jenny
153
+
guido
88
154
```
89
155
90
-
The admin user will have the ability to add more users in the JupyterHub admin console.
156
+
The admin user will have the ability to add more users through JupyterHub's
157
+
admin console.
91
158
92
-
1. Use [docker-compose](https://docs.docker.com/compose/reference/) to build the
93
-
JupyterHub Docker image on the active Docker machine host:
159
+
1. Use [docker-compose](https://docs.docker.com/compose/reference/) to build
160
+
the JupyterHub Docker image on the active Docker machine host by running
161
+
the `make build` command:
94
162
95
-
```
96
-
make build
97
-
```
163
+
```bash
164
+
make build
165
+
```
98
166
99
-
## Prepare the Jupyter Notebook Image
167
+
168
+
## Spawner: Prepare the Jupyter Notebook Image
100
169
101
170
You can configure JupyterHub to spawn Notebook servers from any Docker image, as
102
171
long as the image's `ENTRYPOINT` and/or `CMD` starts a single-user instance of
@@ -126,36 +195,48 @@ Notebook server that is compatible with JupyterHub).
126
195
127
196
You can pull the image using the following command:
128
197
129
-
```
198
+
```bash
130
199
make notebook_image
131
200
```
132
201
202
+
133
203
## Run JupyterHub
134
204
135
205
Run the JupyterHub container on the host.
136
206
137
207
To run the JupyterHub container in detached mode:
138
208
139
-
```
209
+
```bash
140
210
docker-compose up -d
141
211
```
142
212
143
213
Once the container is running, you should be able to access the JupyterHub console at
144
214
215
+
**file**
145
216
```
146
217
https://myhost.mydomain
147
218
```
148
219
149
220
To bring down the JupyterHub container:
150
221
151
-
```
222
+
```bash
152
223
docker-compose down
153
224
```
154
225
226
+
---
227
+
155
228
## Behind the scenes
156
229
157
230
`make build` does a few things behind the scenes, to set up the environment for JupyterHub:
158
231
232
+
### Create a JupyterHub Data Volume
233
+
234
+
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.
235
+
236
+
```bash
237
+
docker volume create --name jupyterhub-data
238
+
```
239
+
159
240
### Create a Docker Network
160
241
161
242
Create a Docker network for inter-container communication. The benefits of using a Docker network are:
@@ -165,25 +246,19 @@ Create a Docker network for inter-container communication. The benefits of usin
165
246
166
247
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.
167
248
168
-
```
249
+
```bash
169
250
docker network create jupyterhub-network
170
251
```
171
252
172
-
### Create a JupyterHub Data Volume
173
-
174
-
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.
175
-
176
-
```
177
-
docker volume create --name jupyterhub-data
178
-
```
253
+
---
179
254
180
255
## FAQ
181
256
182
257
### How can I view the logs for JupyterHub or users' Notebook servers?
183
258
184
259
Use `docker logs <container>`. For example, to view the logs of the `jupyterhub` container
185
260
186
-
```
261
+
```bash
187
262
docker logs jupyterhub
188
263
```
189
264
@@ -197,14 +272,15 @@ JupyterHub reads the Notebook image name from `jupyterhub_config.py`, which
197
272
reads the Notebook image name from the `DOCKER_NOTEBOOK_IMAGE` environment
0 commit comments