> For the complete documentation index, see [llms.txt](https://docs.kiloiot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/getting-started/installation-docker-compose.md).

# Installation: Docker Compose

Installieren Sie KiloCenter mit Docker Compose — starten Sie den MIOTY-Stack mit vier Diensten einschließlich KC-Web, ohne Host-Toolchain.

### Ziel

Starten Sie einen funktionsfähigen lokalen Stack mit Docker Compose. Der gesamte Stack — einschließlich KC-Web — läuft vollständig in Containern. Eine Go-Toolchain auf dem Host oder eine Bun-Laufzeitumgebung ist nicht erforderlich.

### Schritt 1: Umgebung konfigurieren

Aus `kilocenter-modules/`:

```bash
cp .env.example .env
```

Bearbeiten `.env` wenn Sie Datenbankzugangsdaten oder das Protokolllevel ändern möchten. Die Standardwerte funktionieren für eine lokale Evaluierung.

### Schritt 2: TLS-Zertifikate generieren

KC-Core benötigt TLS-Zertifikate für BSSCI und SCACI. Generieren Sie sie mit dem `certgen` im KC-Core-Image integrierten Dienst:

```bash
docker compose run --rm certgen
```

> **Dateibesitz (Linux):** Wenn die erzeugten Dateien root gehören, führen Sie es erneut aus mit `UID=$(id -u) GID=$(id -g)` vorangestellt.

Dadurch werden vier Dateien erstellt in `KC-Core/certificates/`:

| Datei        | Zweck                                                                                         |
| ------------ | --------------------------------------------------------------------------------------------- |
| `ca.crt`     | CA-Zertifikat (an Basisstationen verteilen)                                                   |
| `ca.key`     | CA-Privatschlüssel (sicher aufbewahren, wird zum Signieren von Client-Zertifikaten verwendet) |
| `server.crt` | Serverzertifikat (wird von den KC-Core-BSSCI/SCACI-TLS-Listenern verwendet)                   |
| `server.key` | Privater Server-Schlüssel                                                                     |

Für einen Produktions-FQDN geben Sie `-server`:

```bash
docker compose run --rm certgen -dir /app/certificates -days 365 -server bssci.example.com
```

> **Wichtig:** KC-Core wird ohne diese Zertifikate nicht starten. Auf der Sicherheitsseite finden Sie die vollständige Referenz zu den certgen-Flags, zur Zertifikatsverlängerung und zur Generierung von Client-Zertifikaten.

### Schritt 3: Alle Dienste starten

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

Dadurch werden alle sieben Laufzeitdienste gebaut und gestartet. Nach einem Rebuild werden bei späteren Starts nach Möglichkeit zwischengespeicherte Layer verwendet.

### Schritt 4: Start überprüfen

```bash
# Prüfen, ob alle Dienste laufen
docker compose ps

# KC-Core-Status
curl -s http://localhost:8086/health

# KC-Gateway-Status
curl -s http://localhost:8087/health

# nginx-gRPC-Web-Proxy überprüfen (200/401/403 = OK; 502/404 = Proxy defekt)
curl -s -o /dev/null -w "%{http_code}" \
  -X POST \
  -H "Content-Type: application/grpc-web+proto" \
  -H "X-Grpc-Web: 1" \
  --data-binary $'\x00\x00\x00\x00\x00' \
  http://localhost/kilocenter.api.v1.KiloCenterService/GetSystemStatus
```

Öffnen Sie dann KC-Web in Ihrem Browser:

* <http://localhost/>

> **Hinweis:** Die MQTT-Integration ist standardmäßig deaktiviert. Der Mosquitto-Broker läuft in Docker, aber KC-Core stellt erst dann eine Verbindung zu ihm her, wenn Sie MQTT in `config/config.docker.yaml`. Siehe MQTT First Steps, wenn Sie bereit sind, MQTT einzurichten.

### Alle Dienste stoppen

```bash
docker compose down
```

Um auch persistente Datenvolumes zu entfernen:

```bash
docker compose down -v
```

***

### Quellcode-Entwicklermodus

Für Mitwirkende, die KC-Core, KC-Gateway und KC-Web aus dem Quellcode ausführen möchten:

#### Schritt 1: Infrastruktur-Container starten

```bash
docker compose up -d postgres redis mosquitto
```

Dadurch werden PostgreSQL (gemappt auf Host-Port 5433), Redis (6379) und Mosquitto (1883) gestartet.

#### Schritt 2: TLS-Zertifikate generieren

Wie oben — verwenden Sie die `certgen` Compose-Dienst:

```bash
docker compose run --rm certgen
```

#### Schritt 3: KC-Web-Abhängigkeiten installieren

Aus `kilocenter-modules/KC-Web/`:

```bash
bun install
```

#### Schritt 4: Alle Dienste aus dem Quellcode starten

Aus `kilocenter-modules/`:

```bash
./start-dev.sh
```

Dadurch werden KC-Core, KC-Gateway und KC-Web gebaut und gestartet. Die Protokolle werden in `logs/runtime/`. KC-Web ist verfügbar unter `http://localhost:5173`.

#### Quellcodedienste stoppen

```bash
./stop-all-services.sh

# Infrastruktur-Container stoppen
docker compose stop postgres redis mosquitto
```


---

# 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.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/getting-started/installation-docker-compose.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.
