https://github.com/touilleio/docker-autoheal
Restart docker containers when marked as unhealthy, (re)written in GO.
https://github.com/touilleio/docker-autoheal
autoheal docker docker-compose health-check healthcheck
Last synced: 5 months ago
JSON representation
Restart docker containers when marked as unhealthy, (re)written in GO.
- Host: GitHub
- URL: https://github.com/touilleio/docker-autoheal
- Owner: touilleio
- Created: 2021-03-12T20:45:23.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-17T07:37:52.000Z (almost 5 years ago)
- Last Synced: 2024-11-16T00:43:34.350Z (over 1 year ago)
- Topics: autoheal, docker, docker-compose, health-check, healthcheck
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Docker autoheal
====
This tool monitors and restarts unhealthy docker containers.
This functionality was proposed to be included with the addition of `HEALTHCHECK`, however didn't go through.
This tool is a workaround till there is native support for `--restart-on-unhealthy` or similar ([https://github.com/docker/docker/pull/22719](https://github.com/docker/docker/pull/22719)).
# Disclaimer
This `docker-autoheal` is a rewrite of [the excellent docker-autoheal](https://github.com/willfarrell/docker-autoheal)
from [Will Farrell](https://twitter.com/willfarrell), but in [golang](https://golang.org/).
It is fully compliant with `willfarrell/docker-autoheal`, plus few goodies such as metrics (see below)
## Compatibility
- `AUTOHEAL_INTERVAL`, `AUTOHEAL_START_PERIOD`, `AUTOHEAL_DEFAULT_STOP_TIMEOUT` and `CURL_TIMEOUT`
are duration and are treated as seconds if no unit provided. For more precision `5` can be written `5s`.
- `DOCKER_SOCK` env variable can be written to more standard `DOCKER_HOST`. `DOCKER_SOCK` can still be used.
# Configuration
## Environment variable to configure docker-autoheal
| Env var name | Default | Description |
|--------------|---------|-------------|
| AUTOHEAL_CONTAINER_LABEL | autoheal | Specify the name of the label optin'ing to autoheal process. A special value `all` means all containers are watched |
| AUTOHEAL_INTERVAL | 5s | Interval at which containers health is checked |
| AUTOHEAL_START_PERIOD | 0s | Warmup time before running the first check |
| AUTOHEAL_DEFAULT_STOP_TIMEOUT | 10s | Time to give to containers before shutting down |
| DOCKER_HOST (or DOCKER_SOCK) | /var/run/docker.sock | Path/URI of docker socket |
| CURL_TIMEOUT | 30s | Timeout when interacting with docker |
## Additional configuration for the containers
| Label name | Description |
|------------|-------------|
| autoheal | if `true` or `AUTOHEAL_CONTAINER_LABEL=all`, means this container is watched |
| autoheal.stop.timeout | Per containers override for stop timeout seconds during restart, as a duration, e.g. `120s` |
# Metrics
| Metrics name | Type | Description |
|--------------|------|-------------|
| check_count | counter | Count how many times containers have been checked |
| check_failure_count | counter | Count how many failures happened trying to check containers |
| restart_count | counter | Count how many containers have been restated |
| restart_failure_count | counter | Count how many restart failures happened |