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
-**Development mode,** in which the local version of the Python code can be run inside the container
22
+
-**Jupyter Notebook / JupyterLab**: You can also run Jupyter Notebook and JupyterLab inside the isolated container.
22
23
23
24
## Installation
24
25
@@ -305,11 +306,95 @@ It is **strongly recommended to use an absolute path in the alias** (otherwise,
305
306
306
307
**Warning:** An alias will allow you to run the script from any folder on your system, and that folder will be available for read-access to the script as `/usr/app/data`.
307
308
309
+
## Jupyter Notebook and JupyterLab
310
+
311
+
You can build isolated containers with Juypter Notebook and JupyterLab.
312
+
313
+
### Building a Notebook Image
314
+
315
+
#### Using the default environment file `notebook.yaml`
316
+
317
+
```bash
318
+
# This will build <username>/notebook:latest
319
+
./build.sh -n
320
+
```
321
+
322
+
#### Using one of the pre-defined environment files
323
+
324
+
```bash
325
+
# This will build <username>/notebook:dataviz from dataviz.yaml
326
+
./build.sh -n dataviz
327
+
# This will build <username>/notebook:openai from openai.yaml
328
+
./build.sh -n openai
329
+
```
330
+
331
+
#### Using your own environment file
332
+
333
+
1. Copy `notebook.yaml` to a new YAML file (e.g. `foo.yaml`) and add modules as needed.
334
+
2. Build the image with
335
+
```bash
336
+
# This will build <username>/notebook:foo from foo.yaml
337
+
./build.sh -n foo
338
+
```
339
+
340
+
### Creating an Alias `nbh` (for 'notebook here')
341
+
342
+
Add the following lines to your `.bash_profile` file, like so:
343
+
344
+
```bash
345
+
# ~/foo/bar/py4docker/ is the absolute path to the project in this example
346
+
alias nbh="bash ~/foo/bar/py4docker/run_notebook.sh"
347
+
```
348
+
**Warning:**
349
+
1. An alias will allow you to run the notebook container from any folder on your system, and that folder will be available for read- and write-access to all code and libraries inside the container.
350
+
2. Symbolic links may allow access to resources outside the current working directory!
351
+
352
+
#### Starting a Notebook Container
353
+
354
+
The notebook containers need write-access and a network connection and are hence not as well isolated as in the Python script modus.
355
+
356
+
The current working directory will be mapped to `/usr/app/src` inside the container.
357
+
358
+
For a list of available notebook images (=environments), you can use the alias`nbh`
359
+
360
+
```bash
361
+
nbh --list
362
+
```
363
+
364
+
or
365
+
366
+
```bash
367
+
./run_notebook.sh --list
368
+
```
369
+
370
+
#### Using the default environment `notebook.yaml`
371
+
372
+
```bash
373
+
# This will start <username>/notebook:latest
374
+
nbh
375
+
```
376
+
377
+
#### Using one of the pre-defined environments
378
+
379
+
```bash
380
+
# This will start <username>/notebook:dataviz
381
+
nbh dataviz
382
+
# This will start <username>/notebook:openai
383
+
nbh openai
384
+
```
385
+
386
+
#### Using your own environment
387
+
388
+
```bash
389
+
# This will start <username>/notebook:foo built from foo.yaml
390
+
nbh foo
391
+
```
392
+
308
393
## Advanced Topics
309
394
310
395
### Access to the Local File System
311
396
312
-
The current working directory will be available as `/usr/app/data` from within the container. By default, it is read-only. If you want to make this writeable, change the line
397
+
The current working directory will be available as `/usr/app/data` from within the container. By default, it is read-only (except in the Jupyter Notebook mode). If you want to make this writeable, change the line
@@ -323,7 +408,6 @@ You can also mount additional local paths using the same syntax.
323
408
324
409
If you want to grant your code **write-access** to the `src` folder in**development mode** permanently, you can use the option `-D`, like so:
325
410
326
-
327
411
```bash
328
412
./run_script.sh -D
329
413
```
@@ -379,10 +463,30 @@ from `run_script.sh`.
379
463
380
464
More advanced settings are possible, e.g. adding a proxy or firewall inside the container that permits access only to a known set of IP addresses or domains and / or logs the outbound traffic.
381
465
466
+
## Updating
467
+
468
+
For updating the Python packages, you should re-built the respective image with `-f` (for 'force'):
469
+
470
+
```bash
471
+
# Script
472
+
./build.sh -f
473
+
# Script development image
474
+
./build.sh -f -d
475
+
# Default notebook image
476
+
./build.sh -fn
477
+
# Notebook image from dataviz.yaml
478
+
./build.sh -fn dataviz
479
+
# Notebook image from openai.yaml
480
+
./build.sh -fn openai
481
+
```
482
+
382
483
## Limitations and Ideas for Improvement
383
484
384
485
- The code is currently maintained for Docker Desktop on Apple Silicon only. It may work on other platforms, but I have no time for testing at the moment. It seems to work on Debian.
385
-
- Expand support for blocking and logging Internet access e.g. by domain or IP ranges is a priority at my side, but non-trivial.
486
+
- Better support for blocking and logging Internet access e.g. by domain or IP ranges is a priority at my side, but non-trivial.
487
+
- The Jupyter Notebook mode has currently no support for bind mounts in Linux file-systems and will hence only work with Docker Desktop.
0 commit comments