Container Health Watcher
Problem
Docker's built-in health checks can tell you a container is unhealthy, but they don't do anything about it - a degraded service just sits in the unhealthy state until someone notices and restarts it by hand. I wanted automated recovery driven by the health status the container already reports, without pulling in an external orchestrator, a database, or any persistent state.
Approach
Built a small Python service that runs a 30-second monitoring cycle over the Docker socket. Each pass it lists running containers, filters to those that opted in with the health-watcher.enable: "true" label, and checks their Docker health status. When a container transitions to unhealthy it records the transition and enforces a per-container grace period; if the container is still unhealthy after the timeout it issues a docker restart, and if it recovers on its own the counters reset. All configuration lives in labels on the monitored containers themselves, and all state lives in memory - there is no database and nothing to persist, so the watcher is fully stateless.
Outcome
A drop-in resilience layer for Docker Compose stacks and self-hosted deployments: add one label to any container with a health check and it gets automatically restarted when it goes bad, after a grace period long enough to avoid restarting on transient blips. This is the health-status-driven successor to my earlier Container Watcher, which restarted containers on a fixed interval - here recovery is triggered by the container's own reported health rather than a timer.