Automatically restart unhealthy Docker containers with webhook notifications
1.6K
Automatically restart unhealthy Docker containers. When a container's healthcheck fails, auto-heal restarts it — no manual intervention needed.
Docker detects unhealthy containers but does nothing about it. Your database hangs, your API deadlocks, your cache runs out of memory — Docker just marks it "unhealthy" and walks away. Auto-heal fixes that.
services:
auto-heal:
image: zachbg/auto-heal:latest
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
AUTOHEAL_CONTAINER_LABEL: all # or label specific containers
# Example: this container will be auto-healed
webapp:
image: nginx
labels:
autoheal: "true"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 5s
retries: 3
| Variable | Default | Description |
|---|---|---|
AUTOHEAL_CONTAINER_LABEL | autoheal | Label to filter containers. Set to all to heal everything |
AUTOHEAL_INTERVAL | 5 | Seconds between health checks |
AUTOHEAL_START_PERIOD | 0 | Seconds to wait before starting |
AUTOHEAL_DEFAULT_STOP_TIMEOUT | 10 | Graceful stop timeout per restart |
AUTOHEAL_WEBHOOK_URL | Notification webhook URL | |
AUTOHEAL_WEBHOOK_TYPE | generic | discord, slack, or generic |
AUTOHEAL_LOG_ALL | false | Log all container statuses each cycle |
| Label | Description |
|---|---|
autoheal=true | Enable auto-healing for this container |
autoheal.stop.timeout=30 | Override stop timeout for this container |
environment:
AUTOHEAL_CONTAINER_LABEL: all
environment:
AUTOHEAL_CONTAINER_LABEL: autoheal
AUTOHEAL_WEBHOOK_URL: https://discord.com/api/webhooks/xxx/yyy
AUTOHEAL_WEBHOOK_TYPE: discord
environment:
AUTOHEAL_INTERVAL: 30
AUTOHEAL_DEFAULT_STOP_TIMEOUT: 30
AUTOHEAL_START_PERIOD: 60
Content type
Image
Digest
sha256:eb3a5ddb5…
Size
16.7 MB
Last updated
6 months ago
docker pull zachbg/auto-heal