services: homeassistant: image: homeassistant/home-assistant:stable container_name: homeassistant # Resource constraints to prevent host exhaustion mem_limit: 2g cpu_shares: 512 security_opt: - no-new-privileges:true # Healthcheck ensures the web interface is responsive healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8123/"] interval: 30s timeout: 10s retries: 3 network_mode: host # Required for discovery features (mDNS, UPnP) volumes: - ./config:/config:rw environment: - TZ=${TIMEZONE:-UTC} # Restart policy for stability restart: unless-stopped