Skip to main content
COSMICBYTEZLABS
NewsSecurityHOWTOsToolsStudyTraining
ProjectsNewsletterHire MeAbout
Subscribe

Press Enter to search or Esc to close

News
Security
HOWTOs
Tools
Study
Training
Projects
Newsletter
Hire Me
About
RSS Feed
Reading List
Subscribe

Stay in the Loop

Get the latest security alerts, tutorials, and tech insights delivered to your inbox.

Subscribe NowFree forever. No spam.
COSMICBYTEZLABS

Your trusted source for IT intelligence, cybersecurity insights, and hands-on technical guides.

1184+ Articles
136+ Guides

CONTENT

  • Latest News
  • Security Alerts
  • HOWTOs
  • Checklists
  • Projects
  • Exam Prep

RESOURCES

  • Search
  • Browse Tags
  • Newsletter Archive
  • Reading List
  • RSS Feed

COMPANY

  • About Us
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CosmicBytez Labs. All rights reserved.

System Status: Operational
  1. Home
  2. Projects
  3. Building a 72-Container Homelab on Docker Compose
Building a 72-Container Homelab on Docker Compose
PROJECTAdvanced

Building a 72-Container Homelab on Docker Compose

A self-hosted infrastructure tour — Traefik 3.6 with wildcard TLS, Authentik SSO, Prometheus/Grafana/Loki monitoring, CrowdSec IDS, and how the compose stack is split across files for sanity at scale.

Dylan H.

Projects

May 5, 2026
3 min read
8-12 hours

Tools & Technologies

DockerDocker ComposeTraefik 3.6AuthentikCrowdSec

Overview

Self-hosting at scale is mostly a problem of organization. Once you cross 20-ish containers, a single docker-compose.yml becomes unmaintainable, services stomp on each other's certificates, and any change risks accidental downtime for the rest of the stack. This writeup walks through how the CosmicBytez homelab keeps 72 containers stable across multiple compose stacks, fronted by a single Traefik instance with automatic Let's Encrypt TLS and SSO via Authentik.

Stack

  • Orchestration: Docker Compose 2.20+
  • Reverse Proxy: Traefik 3.6 (CloudFlare DNS challenge, wildcard TLS)
  • Authentication: Authentik SSO (forward auth middleware)
  • Monitoring: Prometheus + Grafana + Loki + Promtail
  • Dashboard: Homepage v1.10.1 (gethomepage.dev)
  • IDS/IPS: CrowdSec v1.7.6
  • Databases: PostgreSQL 16-17, MariaDB 10.11.16, Redis 7.4.7

Compose Stack Layout

Stack FileServices
compose.ymlMaster file (includes all stacks)
stack-core-infra.ymlTraefik, CrowdSec, Homepage, Portainer
stack-arr.ymlSonarr, Radarr, Lidarr, Bazarr, Prowlarr, Seerr
stack-media-books.ymlAudioBookshelf, Calibre-Web, Bookshelf
stack-monitoring.ymlPrometheus, Grafana, Loki, Promtail, exporters
authentik/docker-compose.ymlSSO (server, worker, PostgreSQL, Redis)
wireguard/docker-compose.ymlVPN + qBittorrent (network namespace tunneling)
nextcloud/docker-compose.ymlFile sync (Nextcloud, MariaDB, Redis)
jellyfin/docker-compose.ymlMedia server
mealie/docker-compose.ymlRecipe manager
frigate/docker-compose.ymlNVR and object detection

Traefik Middleware

FilePurpose
middlewares-authentik.ymlForward auth to Authentik outpost + chain-no-auth
middlewares-crowdsec.ymlCrowdSec bouncer plugin
middlewares-headers.ymlSecurity headers (HSTS, X-Frame-Options, CSP)
external-services.ymlRoutes to host-network services like Frigate

Networks

NetworkPurpose
proxyExternal — all Traefik-routed services
wireguard_lan_staticInternal LAN access

Scheduled Tasks (Cron)

ScheduleTask
0 2 * * 0Kometa weekly (franchise collections)
0 3 * * 1-6Kometa nightly
0 4 * * *docker system prune -f (daily cleanup)
0 5 * * 0update.sh (weekly stack update)
*/15 * * * *qBittorrent memory watchdog (8GB threshold)

Lessons Learned

  • qBittorrent inside a network namespace: network_mode: service:wireguard forces traffic through the VPN. Traefik labels go on the WireGuard service, not qBittorrent.
  • qBittorrent memory leak: libtorrent leaks memory; a watchdog auto-restarts at the 8GB threshold.
  • Nextcloud trusted proxies: must match the Traefik subnet exactly, or login redirects loop.
  • Frigate uses network_mode: host: routed via external-services.yml because Traefik can't see it on a Docker network.
  • Loki is distroless: no shell, wget, or curl, so Docker healthchecks must be omitted.
  • All images pinned to exact patch versions: :latest is banned in this stack — exceptions are forks tracked by branch.

Security Hardening

  • no-new-privileges:true on every service
  • Docker socket mounted read-only for Traefik and Portainer
  • CloudFlare API token stored as a Docker secret
  • All .env files gitignored
  • cAdvisor uses cap_add instead of privileged: true
  • Every UI service sits behind Authentik forward auth — no anonymous Grafana, no anonymous Loki
#Docker#Docker Compose#Traefik#Authentik#Homelab#Monitoring#Self-Hosted

Related Articles

Build a Production Monitoring Stack with Prometheus and Grafana

Deploy a full observability stack — Prometheus metrics collection, Grafana dashboards, AlertManager notifications, and three exporters — all containerized...

8 min read

Building a Production-Ready Reverse Proxy with Traefik v3 and Docker

Deploy Traefik v3 as a Docker-native reverse proxy with automatic Let's Encrypt TLS, label-based routing, and security middleware — no more port juggling...

10 min read

Homelab Media Server with Full ARR Stack

Deploy a complete self-hosted media automation system with Plex, Sonarr, Radarr, Prowlarr, and more. Includes Traefik reverse proxy, Authentik SSO, and...

7 min read
Back to all Projects