8000 GitHub - uma-pi1/pi1-docker: One environment with all containers for the lectures of the PI1 chair.
[go: up one dir, main page]

Skip to content

One environment with all containers for the lectures of the PI1 chair.

Notifications You must be signed in to change notification settings

uma-pi1/pi1-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi1-docker: The Environment For All Lectures at PI1

In the following, we briefly introduce you to Docker. For specifics to PI2 , ML/DL, and LSDM, click on the respective link.

Table of contents

  1. Installation
  2. Setup
  3. Usage
  4. PI2
  5. ML/DL

1. Installation

Before starting the local development environment, you need to install Docker. If you have no prior experience with Docker, please refer to the introductory material available on the official Docker website.

Docker Installation - Windows

To use Docker on Windows install the Docker Desktop. We encourage you to use the WSL2 (Windows Subsystem for Linux) as backend. You can find the download link and corresponding installation instructions here.

Troubleshooting WSL

Docker in the WSL can use up too many resources. We therefore limit the RAM usage with the following commands.

Create the file

C:\Users\<username>\.wslconfig

with the following content

[wsl2]
memory=3GB

You can adapt the memory usage to your system. Furthermore, you can limit the amount of processors used by adding processors=1.

Starting the Docker Engine

On Windows you always need to start Docker first manually. Open Docker Desktop and click the little Docker icon in the bottom left corner to start the engine.

Docker Installation - Mac

To use Docker on Mac install the Docker Desktop. You can find the download link and corresponding installation instructions here.

Docker Installation - Linux

On Linux you have multiple installation options.

Installation using Apt

You can install docker using apt (preferred in Debian/Ubuntu). Please follow the official instuctions given here.

Installation using convenience script

Alternatively, Docker provides a useful convenience script to install the engine with the following commands.

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh

For more information see here.

Installation using Snap

Alternatively, you can install docker using a single command on Ubuntu using Snap. Note: the version provided by snap can be an older one. We recommend using the convenience script instead.

sudo snap install docker

2. Setup

Clone This Repository

Clone this repository and go into the root directory of the repository by typing the following commands in a terminal:

git clone https://github.com/uma-pi1/pi1-docker
cd pi1-docker

Alternatively, you can click on the "Code" button on the top right of this page and click "Download ZIP". Then you need to decompress the ZIP file into a new folder.

Build/Start Docker Containers

With an installed Docker environment and a started engine you can now run the Docker containers.

Note: The first time you are running the commands below will take some time depending on your notebook and internet connection. So feel free to grab some coffee.

It will only take that long the first time you run this command. All following start-ups should be quick.

This will run all provided containers:

docker compose up -d

You usually want to use the pi1_main container only. Start this using

docker compose up -d pi1-main

Note for Windows users: it might be that you do not have write access in the shared/ folder. In that case, first run prepare_host.sh. For this, open a linux shell, turn the script into an executable, then run it.

chmod +x prepare_host.sh
./prepare_host.sh

Then run docker compose up --build.

Handling Repository Updates

If the pi1-docker repository was updated during the term, run

git pull
docker compose up --build -d

in the pi1-docker folder.

3. Usage

Use the Docker Desktop GUI or run the following command in the root folder of the repository to start the main container:

docker compose up -d pi1-main

The container will run until you stop it using the GUI or

docker compose down

Transfer Files Between Host and Container

All files placed in the folder ./shared located in the root directory of this repository on your host machine will directly appear in your container in the folder shared. And vice versa, of course.

Using JupyterLab

Open a browser and enter http://localhost:8889 to open JupyterLab. You have the option to open a terminal or notebooks for multiple different languages.

If you see a prompt asking you for a token or password type pi1.

JupyText

In our lectures, we are making use of Jupytext, a tool to synchronize plain Python files with Jupyter notebooks. In this Docker container, Jupytext is already installed. This means that you are able to open and edit plain Python files as a notebook. You will notice that upon saving your edits, a notebook file (with ipynb file extension) will be created. Changes in either file (py or ipynb) will be synchronized to the other one.

Note: If Python files are not opened as a notebook directly, right-click the file, click "Open With", then select "Notebook".

Run Programs in A Container

You can run programs using the terminal in JupyterLab. But you can also do it non-interactively or interactively from the shell.

Non-Interactively

  1. List Running Containers: If you don't know the exact container name, list the running containers to get the container ID or name.

    docker ps
  2. Execute a Command: Run your command via the container

    sh docker exec -it <container_name> <command>
    

    For example, to run a Python script inside pi1-main:

    docker exec -it pi1-main python3 shared/myprogram.py

Interactively

Attach to the container's interactive shell using the docker exec command with bash.

  1. Attach to the Shell: Use the docker exec command to attach to the container's shell.

    docker exec -it <container_name> /bin/bash
  2. Execute programs: Once you are inside the container's shell, you can execute programs as you would in a regular terminal.

    For example, to compile and run a C program:

    gcc -o myprogram myprogram.c
    ./myprogram
  3. Close the shell again: Ctrl+D.

Misc

The default user name in JupyterLab and the pi1-main notebook is jovyan. For more information see here.

""Jovyan is often a special term used to describe members of the Jupyter community. It is also used as the user ID in the Jupyter Docker stacks or referenced in conversations."

4. PI2

For the lecture Praktische Informatik II (PI2), the Docker environment contains:

  • clang
  • nasm
  • Java
  • Python
  • JupyterLab with Java and C kernels

5. ML/DL< 56B1 /h2>

For the lectures "Machine Learning (ML)" and "Deep Learning (DL)", the Docker environement contains:

  • JupyterLab with Python kernel
  • Relevant Python packages including matplotlib, pandas, NumPy, PyTorch, and TensorBoard

About

One environment with all containers for the lectures of the PI1 chair.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0