- Docker installed
- Jupyter installed
Required files to build the image:
- Dockerfile
- requirements.txt
docker build -t <name of image> .
Run built image with command
docker run -it --name <name of container> -p 8888:8888 <name image>
if there is no local image with the name, the Docker daemon searches and downloads image e.g. "jupyter/base-notebook" from Docker hub
run Jupyter notebook e.g. through VS Code or in browser with http://localhost:8888/
(enter server ID / token, which is in Terminal output when container is started, is needed)
- interaction between container and jupyter notebooks
- new libraries can be installed either on
- image, rebuild of image and container required
- container, with jupyter notebook
(1) restart container
docker start <containerID e.g. from Docker Desktop>
(2) get Jupyter URL from logs
docker logs <containerID e.g. from Docker Desktop>
(3) use Jupyter notebook with libraries
usage
- develop and execute code inside a container
- the file
devcontainer.json
tells the VS Code Dev Container extension how to create and access Dev Containers
commandpalette
Dev Containers: Add Dev Container Configuration Files
creates a newdevcontainer.json
template file and an optional Dockerfile, which both can be further adjustedDev Containers: New Dev Container
builds and starts new Dev containerDev Containers: Rebuild and Reopen in Container
- specify libraries in requirements.txt
- build container again after changes
- cheat sheet for Docker CLI commands https://docs.docker.com/get-started/docker_cheatsheet.pdf