A production-ready Docker container monitoring and auto-healing service with a modern React web interface. Automatically monitors your Docker containers for failures and unhealthy states, restarting them intelligently based on configurable policies.
docker run -d \
--name docker-autoheal \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ./data:/data \
-p 3131:3131 \
-p 9090:9090 \
--restart unless-stopped \
swaya1125/docker-autoheal:latest
Access the Web UI: http://localhost:3131ā
/data volumeautoheal=true) or all containers/data)/var/run/docker.sock)docker run -d \
--name docker-autoheal \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-p 3131:3131 \
swaya1125/docker-autoheal:latest
docker run -d \
--name docker-autoheal \
--restart unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /path/to/data:/data \
-p 3131:3131 \
-p 9090:9090 \
-e AUTOHEAL_INTERVAL=30 \
-e AUTOHEAL_LOG_LEVEL=INFO \
swaya1125/docker-autoheal:latest
version: '3.8'
services:
autoheal:
image: swaya1125/docker-autoheal:latest
container_name: docker-autoheal
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data:/data # Persist configuration and state
ports:
- "3131:3131" # Web UI
- "9090:9090" # Prometheus metrics
environment:
- AUTOHEAL_INTERVAL=30
- AUTOHEAL_LOG_LEVEL=INFO
# Example monitored container
webapp:
image: nginx:latest
labels:
autoheal: "true" # Enable auto-healing for this container
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 3
Then start:
docker-compose up -d
Enable auto-healing on specific containers using labels:
services:
myapp:
image: myapp:latest
labels:
autoheal: "true" # Enable monitoring
autoheal.stop.timeout: "30" # Custom stop timeout
| Label | Description | Default |
|---|---|---|
autoheal | Enable monitoring (true or false) | Matches config |
autoheal.stop.timeout | Seconds to wait before force-stopping | 10 |
| Variable | Description | Default |
|---|---|---|
AUTOHEAL_INTERVAL | Monitoring interval in seconds | 30 |
AUTOHEAL_LOG_LEVEL | Log level (DEBUG, INFO, WARNING, ERROR) | INFO |
AUTOHEAL_LABEL_KEY | Label key to filter containers | autoheal |
AUTOHEAL_LABEL_VALUE | Label value to filter containers | true |
All settings can be configured through the web interface at http://localhost:3131:
Configuration is automatically persisted to /data/config.json. You can:
Metrics are exposed on port 9090 at /metrics:
curl http://localhost:9090/metrics
Available metrics:
Service health endpoint:
curl http://localhost:3131/health
View logs:
docker logs -f docker-autoheal
Logs are also persisted to /data/logs/autoheal.log
autoheal=true label (if label filtering is enabled)docker logs docker-autohealAUTOHEAL_LOG_LEVEL=DEBUGdocker run --rm -v /var/run/docker.sock:/var/run/docker.sock alpine ls -l /var/run/docker.sock
When a container restarts too frequently, it's automatically quarantined:
This service requires read-only access to the Docker socket. While necessary for monitoring, this grants significant privileges. Best practices:
:roFor production:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Docker Auto-Heal Container ā
ā ā
ā āāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
ā ā React UI āāāāāāāŗā FastAPI ā ā
ā ā (Port 3131)ā ā Backend ā ā
ā āāāāāāāāāāāāāā āāāāāāāā¬āāāāāāāā ā
ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāā ā
ā ā Monitor Service ā ā
ā ā - Health checks ā ā
ā ā - Restart logic ā ā
ā ā - Event logging ā ā
ā āāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāā ā
ā ā ā
āāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāā
ā
ā¼
/var/run/docker.sock
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Docker Engine ā
ā (Host System) ā
āāāāāāāāāāāāāāāāāāā
http://localhost:3131/docs (Swagger UI)MIT License - see LICENSE file for details
Contributions welcome! Please see the GitHub repository for guidelines.
Built with ā¤ļø using Python, FastAPI, React, and Docker
Content type
Image
Digest
sha256:f7e290c1fā¦
Size
75.6 MB
Last updated
10 months ago
docker pull swaya1125/docker-autoheal