📚 Improved Docker Troubleshooting documentation and code optimizations in backend utilities. 🖥️🔧
This commit is contained in:
209
README-Docker-Troubleshooting.md
Normal file
209
README-Docker-Troubleshooting.md
Normal file
@ -0,0 +1,209 @@
|
||||
# Docker Build Troubleshooting - MYP System
|
||||
|
||||
Lösungen für häufige Docker-Build-Probleme beim MYP (Manage Your Printers) System.
|
||||
|
||||
## 🐛 Problem: Package 'ping' has no installation candidate
|
||||
|
||||
### Fehlermeldung:
|
||||
```
|
||||
E: Package 'ping' has no installation candidate
|
||||
```
|
||||
|
||||
### ✅ Lösung:
|
||||
Das Paket `ping` ist ein virtuelles Paket. Verwende stattdessen `iputils-ping`.
|
||||
|
||||
**Korrigiertes Dockerfile:**
|
||||
```dockerfile
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
iputils-ping \
|
||||
sqlite3 \
|
||||
openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
```
|
||||
|
||||
## 🐛 Problem: Docker Compose nicht verfügbar in WSL2
|
||||
|
||||
### Fehlermeldung:
|
||||
```
|
||||
The command 'docker-compose' could not be found in this WSL 2 distro.
|
||||
```
|
||||
|
||||
### ✅ Lösungen:
|
||||
|
||||
#### Option 1: Docker Desktop WSL2 Integration
|
||||
1. Öffne Docker Desktop
|
||||
2. Gehe zu Settings → Resources → WSL Integration
|
||||
3. Aktiviere WSL2-Integration für deine Distribution
|
||||
|
||||
#### Option 2: Manueller Docker Compose Download
|
||||
```bash
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
```
|
||||
|
||||
#### Option 3: Verwende das vereinfachte Dockerfile
|
||||
```bash
|
||||
# Verwende Dockerfile.simple für weniger Komplexität
|
||||
docker build -f Dockerfile.simple -t myp-system:test .
|
||||
```
|
||||
|
||||
## 🐛 Problem: Frontend-Build-Fehler
|
||||
|
||||
### Fehlermeldung:
|
||||
```
|
||||
COPY failed: file not found in build context
|
||||
```
|
||||
|
||||
### ✅ Lösung:
|
||||
Stelle sicher, dass alle erforderlichen Dateien existieren:
|
||||
|
||||
```bash
|
||||
# Prüfe ob package.json existiert
|
||||
ls -la backend/package.json
|
||||
|
||||
# Erstelle fehlende Verzeichnisse
|
||||
mkdir -p backend/static/css
|
||||
mkdir -p backend/templates
|
||||
```
|
||||
|
||||
**Vereinfachtes Dockerfile ohne Node.js:**
|
||||
```dockerfile
|
||||
# Verwende Dockerfile.simple ohne Frontend-Build
|
||||
FROM python:3.11-slim-bullseye
|
||||
# ... nur Python-Dependencies
|
||||
```
|
||||
|
||||
## 🐛 Problem: Datenbankpfad-Probleme
|
||||
|
||||
### Fehlermeldung:
|
||||
```
|
||||
sqlite3.OperationalError: unable to open database file
|
||||
```
|
||||
|
||||
### ✅ Lösung:
|
||||
Korrekte Datenbankpfad-Konfiguration:
|
||||
|
||||
**In `utils/utilities_collection.py`:**
|
||||
```python
|
||||
DATABASE_PATH = "database/myp.db" # Relativ zu backend/
|
||||
```
|
||||
|
||||
**Docker-Volumes:**
|
||||
```yaml
|
||||
volumes:
|
||||
- myp-database:/app/database
|
||||
```
|
||||
|
||||
## 🛠️ Debugging-Befehle
|
||||
|
||||
### Container-Status prüfen
|
||||
```bash
|
||||
# Build-Logs anzeigen
|
||||
docker build -f Dockerfile.simple -t myp-system:debug . --progress=plain
|
||||
|
||||
# Container starten mit Debug-Output
|
||||
docker run --rm -it myp-system:debug bash
|
||||
|
||||
# Container-Logs live verfolgen
|
||||
docker logs -f container_name
|
||||
```
|
||||
|
||||
### Verzeichnisstruktur prüfen
|
||||
```bash
|
||||
# Lokale Struktur
|
||||
find . -name "*.py" | head -10
|
||||
ls -la backend/
|
||||
|
||||
# Im Container
|
||||
docker run --rm -it myp-system:debug ls -la /app/
|
||||
```
|
||||
|
||||
### Network-Tests
|
||||
```bash
|
||||
# Container-Netzwerk testen
|
||||
docker run --rm myp-system:debug ping -c 2 google.com
|
||||
|
||||
# Port-Tests
|
||||
docker run --rm -p 8080:5000 myp-system:debug
|
||||
curl http://localhost:8080/
|
||||
```
|
||||
|
||||
## 🔧 Schnell-Fixes
|
||||
|
||||
### 1. Vereinfachtes Setup
|
||||
```bash
|
||||
# Verwende setup-docker.sh für automatische Installation
|
||||
sudo ./setup-docker.sh
|
||||
```
|
||||
|
||||
### 2. Ohne Docker Compose
|
||||
```bash
|
||||
# Direkter Docker-Build
|
||||
docker build -f Dockerfile.simple -t myp-system .
|
||||
docker run -d -p 80:5000 --name myp-http myp-system
|
||||
docker run -d -p 443:5000 --name myp-https myp-system
|
||||
docker run -d -p 5000:5000 --name myp-dev myp-system
|
||||
```
|
||||
|
||||
### 3. Test-Build
|
||||
```bash
|
||||
# Verwende Test-Skript
|
||||
./test-docker-build.sh
|
||||
```
|
||||
|
||||
## 📋 Build-Checkliste
|
||||
|
||||
Vor dem Docker-Build prüfen:
|
||||
|
||||
- [ ] `backend/requirements.txt` existiert
|
||||
- [ ] `backend/package.json` existiert
|
||||
- [ ] `database/` Verzeichnis existiert
|
||||
- [ ] `Dockerfile.simple` ist verfügbar
|
||||
- [ ] Docker-Daemon läuft
|
||||
- [ ] Ausreichend Speicherplatz (>2GB)
|
||||
|
||||
## 🎯 Produktions-Setup
|
||||
|
||||
Für stabiles Produktions-Deployment:
|
||||
|
||||
```bash
|
||||
# 1. System vorbereiten
|
||||
sudo ./setup-docker.sh
|
||||
|
||||
# 2. Container starten
|
||||
docker-compose up -d
|
||||
|
||||
# 3. Status prüfen
|
||||
docker-compose ps
|
||||
docker-compose logs -f
|
||||
|
||||
# 4. Health-Checks
|
||||
curl -f http://localhost:80/
|
||||
curl -k -f https://localhost:443/
|
||||
curl -f http://localhost:5000/
|
||||
```
|
||||
|
||||
## 📞 Support
|
||||
|
||||
Bei weiteren Problemen:
|
||||
|
||||
1. **Logs sammeln:**
|
||||
```bash
|
||||
docker-compose logs > docker-logs.txt
|
||||
./setup-docker.sh > setup-logs.txt
|
||||
```
|
||||
|
||||
2. **System-Info:**
|
||||
```bash
|
||||
docker --version
|
||||
docker-compose --version
|
||||
df -h
|
||||
free -h
|
||||
```
|
||||
|
||||
3. **Fehler melden** mit vollständigen Log-Ausgaben
|
||||
|
||||
**Mercedes-Benz TBA Marienfelde**
|
||||
**Autor**: Till Tomczak
|
||||
**E-Mail**: till.tomczak@mercedes-benz.com
|
Reference in New Issue
Block a user