> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/german/hauptfunktionen/headless/docker-example.md).

# Docker-Beispiel

Diese Seite zeigt ein reproduzierbares Docker-Setup, um ein AugeLab Studio `.pmod`-Szenario headless auszuführen.

Das Image wird lokal aus einem Dockerfile gebaut. Kund:innen benötigen nicht den AugeLab-Quellcode. Der Container installiert das Closed-Source-Paket `studio` aus dem AugeLab-Paketindex während des Image-Builds.

## Voraussetzungen

* Docker Desktop oder Docker Engine mit Docker Compose.
* Zugriff auf den AugeLab-Paketindex.
* Ein AugeLab-Verifizierungscode.
* Eine `.pmod`-Szenario-Datei, die headless laufen kann.
* Für GPU/CUDA: NVIDIA Container Toolkit auf dem Host installiert.

## Schnellstart

1. Erstelle die untenstehende Ordnerstruktur.
2. Lege deine `.pmod`-Datei in `app/`.
3. Füge deinen Verifizierungscode in `.env` ein.
4. Verwende das CPU- oder das GPU-Dockerfile.
5. Führe `docker compose up --build` aus.
6. Prüfe `output_on_host`.

## Projektstruktur

```
augelab-docker-example/
  .env
  docker-compose.yml
  docker-compose.cuda.yml
  output_on_host/
  app/
    Dockerfile
    Dockerfile.cuda
    run_scenario.py
    your_scenario.pmod
```

Ersetze `your_scenario.pmod` durch deine eigene Szenario-Datei.

## .env-Datei

Erstelle `.env` neben `docker-compose.yml`:

<details>

<summary>.env</summary>

```env
AUGELAB_VERIFICATION_CODE=PASTE_YOUR_VERIFICATION_CODE_HERE
SCENARIO_PATH=your_scenario.pmod
```

</details>

Wenn `.env` einen echten Verifizierungscode enthält, nicht ins Versionskontrollsystem committen.

## Szenario-Ausführungsskript

Erstelle `app/run_scenario.py`:

<details>

<summary>app/run_scenario.py</summary>

```python
import os
from pathlib import Path

from studio import StudioScenario


OUTPUT_DIR = Path("/app/app_output")
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)

verification_code = os.environ.get("AUGELAB_VERIFICATION_CODE")
if not verification_code:
    raise RuntimeError("AUGELAB_VERIFICATION_CODE is not set.")

scenario_path = os.environ.get("SCENARIO_PATH", "your_scenario.pmod")
if not Path(scenario_path).is_file():
    raise FileNotFoundError(f"Scenario file not found: {scenario_path}")

scenario = StudioScenario(verification_code=verification_code)
scenario.enable_logging_stdout()
scenario.load_scenario(scenario_path)

try:
    print("Scenario result:", scenario.run())
finally:
    scenario.cleanup()
```

</details>

Wenn dein Szenario Dateien schreibt, konfiguriere es so, dass sie unter `/app/app_output` abgelegt werden.

## CPU-Dockerfile

Dieses Dockerfile ist für reguläre headless CPU-Läufe:

<details>

<summary>app/Dockerfile</summary>

```dockerfile
FROM python:3.12-slim-bookworm

WORKDIR /app

RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
    libdmtx0b \
    zbar-tools \
    build-essential \
    libgl1-mesa-glx \
    curl \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

ADD https://astral.sh/uv/0.9.17/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh

ENV PATH="/root/.local/bin/:$PATH"

RUN uv pip install studio --system \
    --extra-index-url https://pyrepo.augelab.com \
    --extra-index-url https://download.pytorch.org/whl/cpu \
    --index-strategy unsafe-best-match

RUN python -c "from studio import StudioScenario; print('studio import ok')"

COPY run_scenario.py .
COPY your_scenario.pmod .

CMD ["python", "run_scenario.py"]
```

</details>

## GPU/CUDA-Dockerfile

Verwende dieses Dockerfile, wenn dein Szenario CUDA-Beschleunigung benötigt. Der Host muss kompatible NVIDIA-Treiber und das NVIDIA Container Toolkit haben.

<details>

<summary>app/Dockerfile.cuda</summary>

```dockerfile
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04

WORKDIR /app

RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
    python3 \
    python3-venv \
    python3-pip \
    libdmtx0b \
    zbar-tools \
    build-essential \
    libgl1-mesa-glx \
    curl \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

ADD https://astral.sh/uv/0.9.17/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh

ENV PATH="/root/.local/bin/:$PATH"
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility

RUN uv pip install "studio[gpu]" --system \
    --extra-index-url https://pyrepo.augelab.com \
    --index-strategy unsafe-best-match

RUN python3 -c "from studio import StudioScenario; print('studio gpu import ok')"

COPY run_scenario.py .
COPY your_scenario.pmod .

CMD ["python3", "run_scenario.py"]
```

</details>

## Compose-Datei

Verwende diese Datei für das CPU-Dockerfile:

<details>

<summary>docker-compose.yml</summary>

```yaml
services:
  augelab-headless:
    build:
      context: ./app
      dockerfile: Dockerfile
    env_file:
      - .env
    volumes:
      - ./output_on_host:/app/app_output
```

</details>

Dies mountet `./output_on_host` aus deinem Projektordner in den Container nach `/app/app_output`.

{% hint style="warning" %}
Unter Windows: Verwende Vorwärtsschrägstriche in absoluten Docker-Mount-Pfaden, z. B. `C:/work/augelab_output:/app/app_output`. Relative Mounts wie `./output_on_host:/app/app_output` sind in der Regel leichter zwischen Maschinen zu teilen.
{% endhint %}

## GPU/CUDA Compose-Datei

Verwende diese Datei für `Dockerfile.cuda`:

<details>

<summary>docker-compose.cuda.yml</summary>

```yaml
services:
  augelab-headless-gpu:
    build:
      context: ./app
      dockerfile: Dockerfile.cuda
    env_file:
      - .env
    volumes:
      - ./output_on_host:/app/app_output
    gpus: all
```

</details>

## Image erstellen und starten

CPU:

```bash
docker compose up --build
```

GPU/CUDA:

```bash
docker compose -f docker-compose.cuda.yml up --build
```

Du solltest die AugeLab Studio-Logs und das Szenarioergebnis im Terminal sehen.

## Ausgabe überprüfen

Prüfe `output_on_host` auf deinem Hostsystem. Dateien, die das Szenario nach `/app/app_output` schreibt, sollten dort erscheinen.

## Fehlerbehebung

| Problem                             | Prüfe                                                                                                                               |
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `studio`-Installation schlägt fehl  | Bestätige Netzwerkzugang und Zugriff auf den AugeLab-Paketindex.                                                                    |
| Lizenz/Aktivierung schlägt fehl     | Prüfe, ob `AUGELAB_VERIFICATION_CODE` gesetzt ist und der Container Internetzugang hat.                                             |
| Szenario-Datei nicht gefunden       | Prüfe, ob `SCENARIO_PATH` mit der durch das Dockerfile kopierten `.pmod` übereinstimmt.                                             |
| Ausgabeordner ist leer              | Prüfe, ob die `.pmod` nach `/app/app_output` schreibt.                                                                              |
| Windows-Volume wird nicht gemountet | Verwende Vorwärtsschrägstriche und bestätige, dass Docker Desktop auf das Laufwerk zugreifen darf.                                  |
| GPU-Container sieht GPU nicht       | Installiere das NVIDIA Container Toolkit und teste mit `docker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu22.04 nvidia-smi`. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.augelab.com/german/hauptfunktionen/headless/docker-example.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
