-
Notifications
You must be signed in to change notification settings - Fork 1
Architecture Overview
This document describes the overall architecture, design principles, and system organization of the Docker Compose orchestration framework.
- Each service stack is independent and reusable
- Services can be deployed individually or in combination
- Clear separation of concerns between service layers
- Minimal coupling between services
- 5 isolated Docker networks for security and organization
- Services only connect to networks they need
- Internal networks prevent external access
- Single external-facing proxy network
- Reliable service orchestration with proper dependency management
- Services start in correct order automatically
- Automatic restart on failure
- Boot-time startup support
- Multi-layered environment system
- Separation of secrets and base configuration
- Machine-specific overrides via
.localfiles - GitOps-friendly (base config committed, secrets ignored)
┌──────────────────────────────────────────────────────────────────┐
│ Internet / Local Network │
└────────────────────┬─────────────────────────────────────────────┘
│
↓
┌───────────────────────┐
│ Traefik (Proxy) │ ← SSL/TLS Termination
│ Port 80/443 │ ← Let's Encrypt + Cloudflare
└───────────┬───────────┘
│
┌───────────┴───────────┐
│ proxy Network │ 172.20.0.0/24
│ (External) │
└───────────┬───────────┘
│
┌───────────────┼───────────────┐
│ │ │
↓ ↓ ↓
┌─────────┐ ┌──────────┐ ┌──────────┐
│Homepage │ │Portainer │ │Services │
│Dashboard│ │Container │ │(WebUI, │
│ │ │ Mgmt │ │Plex,etc) │
└─────────┘ └──────────┘ └────┬─────┘
│
┌───────────┼───────────┐
│ │ │
↓ ↓ ↓
┌────────────┐ ┌────────┐ ┌────────┐
│ database │ │ genai │ │ auth │
│ Network │ │Network │ │Network │
│172.22.0/24 │ │172.23/ │ │172.24/ │
│ (Internal) │ │(Intern)│ │(Intern)│
└─────┬──────┘ └───┬────┘ └────────┘
│ │
┌───────────┼─────────────┼──────────┐
↓ ↓ ↓ ↓
┌─────────┐ ┌─────────┐ ┌────────┐ ┌────────┐
│MongoDB │ │Postgres │ │Ollama │ │LibreChat│
│ │ │pgvector │ │(LLM) │ │ │
└─────────┘ └─────────┘ └────────┘ └────────┘
↓ ↓ ↓ ↓
┌─────────┐ ┌─────────┐ ┌────────┐ ┌────────┐
│Qdrant │ │(Data │ │OpenWebUI│ │SwarmUI │
│(Vector) │ │Storage) │ │ │ │(Stable │
│ │ │ │ │ │ │Diffusion│
└─────────┘ └─────────┘ └────────┘ └────────┘
Purpose: Essential services for routing, management, and monitoring
Services:
- Traefik: Reverse proxy with automatic SSL/TLS
- Portainer: Docker container management UI
- Homepage: Unified dashboard for all services
Network: proxy (172.20.0.0/24) - External-facing
Dependencies: None (starts first)
Startup Order: 1st
Purpose: Centralized data storage and databases
Services:
- MongoDB: NoSQL document database
- PostgreSQL + pgvector: SQL with vector embeddings
- Qdrant: Specialized vector database (GPU-accelerated)
Network: database (172.22.0.0/24) - Internal only
Dependencies: None (but typically starts after panel)
Startup Order: 2nd
Purpose: Artificial intelligence and machine learning capabilities
Services:
- Ollama: Local LLM inference engine
- Open WebUI: Web interface for LLMs
- LibreChat: Advanced chat application
- Text Embeddings: HuggingFace TEI service
- SwarmUI: Stable Diffusion image generation
- RisuAI: Character AI and roleplay
Networks:
- genai (172.23.0.0/24) - Internal
- database (for data storage)
- proxy (for web access)
Dependencies: database, panel
Startup Order: 3rd
Purpose: Media streaming and management
Services:
- Plex Media Server: Media streaming (GPU transcoding)
- Tautulli: Plex analytics
- StashApp: Personal media manager
Networks:
- proxy (for web access)
- database (optional, for metadata)
Dependencies: panel
Startup Order: 3rd or 4th
See Network Topology for detailed network configuration.
Network Isolation Strategy:
| Network | Subnet | Type | Purpose | Services |
|---|---|---|---|---|
| proxy | 172.20.0.0/24 | External | Internet-facing | Traefik, all web services |
| database | 172.22.0.0/24 | Internal | Data persistence | MongoDB, PostgreSQL, Qdrant |
| genai | 172.23.0.0/24 | Internal | AI/ML isolation | Ollama, embedding services |
| metrics | 172.21.0.0/24 | Internal | Monitoring (future) | Prometheus, Grafana |
| auth | 172.24.0.0/24 | Internal | Authentication (future) | Authelia, OAuth providers |
Benefits:
- ✅ Security through isolation
- ✅ Clear service boundaries
- ✅ Prevents lateral movement
- ✅ Organized traffic flow
- ✅ Easier firewall rules
User Browser
↓
HTTPS (443)
↓
Traefik (proxy network)
↓
TLS Termination + Routing
↓
Open WebUI (genai + proxy networks)
↓
HTTP (internal)
↓
Ollama (genai network)
↓
Vector lookup
↓
Qdrant (database + genai networks)
systemd starts services
↓
1. panel (Traefik, Portainer, Homepage)
↓
Wait for Traefik ready
↓
2. database (MongoDB, PostgreSQL, Qdrant)
↓
Wait for databases ready
↓
3. genai services (Ollama, OpenWebUI, etc.)
↓
Wait for dependencies ready
↓
All services running
${DATA_DIR}/ (default: /mnt/data/compose)
├── panel/
│ ├── traefik/ # Traefik configuration and certificates
│ ├── portainer/ # Portainer data
│ └── homepage/ # Homepage configuration
├── database/
│ ├── mongo/ # MongoDB data files
│ ├── postgres/ # PostgreSQL data files
│ └── qdrant/ # Qdrant vector storage
├── genai/
│ ├── ollama/ # Ollama models
│ ├── openwebui/ # Open WebUI data
│ ├── librechat/ # LibreChat data
│ ├── embedding/ # Embedding models
│ └── swarmui/ # Stable Diffusion models
├── plex/
│ ├── config/ # Plex configuration
│ ├── transcode/ # Transcoding temp files
│ └── media/ # Media library (symlink)
└── stash/
└── data/ # StashApp data
- Named volumes: For database-specific data (performance)
- Bind mounts: For configuration and shared data
- User namespace mapping: Containers use mapped UIDs/GIDs
- Persistent storage: All data survives container recreation
- Network Isolation: Services only on required networks
- TLS Everywhere: All external access via HTTPS
- User Namespace Remapping: Containers don't run as root
-
Secret Management:
.localfiles for sensitive data - Minimal Exposure: Only Traefik exposes ports externally
┌─────────────────────────────────────────┐
│ External Zone (proxy network) │
│ - Traefik only │
│ - SSL/TLS termination │
│ - Exposed ports: 80, 443 │
└──────────────┬──────────────────────────┘
│
┌──────────────┴──────────────────────────┐
│ Service Zone (proxy + internal) │
│ - Web applications │
│ - Access via Traefik only │
└──────────────┬──────────────────────────┘
│
┌──────────────┴──────────────────────────┐
│ Data Zone (internal networks only) │
│ - Databases │
│ - No external access │
│ - Access from service zone only │
└──────────────────────────────────────────┘
Characteristics:
- Single server
- Behind NAT/firewall
- Cloudflare DNS for certificates
- No public exposure required
Configuration:
- Use Cloudflare DNS challenge
- All services on same host
- Local network access + VPN for remote
Characteristics:
- Public IP address
- Internet-facing services
- Cloud provider (AWS, GCP, Hetzner, etc.)
Configuration:
- Direct Let's Encrypt HTTP challenge
- Firewall rules (80, 443 only)
- Consider DDoS protection
Characteristics:
- Docker Swarm or Kubernetes
- Distributed services
- Shared storage required
Configuration:
- Overlay networks
- NFS/Ceph for shared volumes
- Load balancing considerations
- Docker Engine: Container runtime
- Docker Compose V2: Service orchestration
- NVIDIA Container Toolkit: GPU support
- systemd: Service lifecycle management
- composectl: Custom systemd controller
- compose wrapper: Enhanced Docker Compose
- Docker Bridge Networks: Network isolation
- Traefik: Reverse proxy and load balancer
- Let's Encrypt: Automatic SSL/TLS certificates
- Bind Mounts: Configuration and shared data
- Named Volumes: Database performance
- User Namespace Remapping: Security
- Python 3.11+: Management scripts
- YAML: Service definitions
- TOML: Network configuration
- Bash: Shell scripts
- Single-host: All services on one machine
- Vertical scaling: Add more CPU/RAM/GPU
- Resource limits: Docker resource constraints
- Service Separation: Move databases to dedicated hosts
- Docker Swarm: Multi-host orchestration
- Kubernetes: Enterprise-grade orchestration
- Load Balancing: Multiple instances of services
- Database Clustering: MongoDB replica sets, PostgreSQL streaming replication
✅ Simple to understand and maintain ✅ No external dependencies (Kubernetes, etc.) ✅ Reliable startup and dependency management ✅ Perfect for homelab and small deployments ✅ Full Docker Compose compatibility
❌ Single-host limitation ❌ Manual scaling required ❌ Not suitable for large-scale production
✅ Multi-host support ✅ Built-in load balancing ❌ More complex setup ❌ Limited ecosystem compared to Kubernetes
✅ Industry standard ✅ Massive ecosystem ✅ Advanced features ❌ Steep learning curve ❌ Overkill for homelab ❌ Resource overhead
- Docker container logs via
docker logs - systemd journal logs via
journalctl - Traefik dashboard for routing
- Portainer for container overview
- Prometheus metrics collection
- Grafana dashboards
- Loki log aggregation
- Alert manager for notifications
See: Network Topology for metrics network setup
Related Pages:
- Network Topology - Detailed network architecture
- Systemd Integration - Service management
- Configuration Management - Environment configuration