Monitor and restart unhealthy docker containers.
3.9K
Monitor and automatically restart unhealthy Docker containers.
The Docker image is available in multiple tag formats:
main (Development Build)
main branch.latest (Stable Release)
A.B.C.D (Versioned Releases)
You can pull the Docker image from either of the following registries:
ghcr.io/journeydocker/docker-autoheal:<tagname>journeyover/docker-autoheal:<tagname>docker run -d \
--name autoheal \
--restart=always \
-e AUTOHEAL_CONTAINER_LABEL=all \
-v /var/run/docker.sock:/var/run/docker.sock \
journeyover/docker-autoheal:main
docker run -d \
--name autoheal \
--restart=always \
-e AUTOHEAL_CONTAINER_LABEL=all \
-e DOCKER_SOCK=tcp://$HOST:$PORT \
-v /path/to/certs/:/certs/:ro \
journeyover/docker-autoheal:main
docker run -d \
--name autoheal \
--restart=always \
--tlscacert=/certs/ca.pem \
--tlscert=/certs/client-cert.pem \
--tlskey=/certs/client-key.pem \
-e AUTOHEAL_CONTAINER_LABEL=all \
-e DOCKER_HOST=tcp://$HOST:2376 \
-e DOCKER_SOCK=tcps://$HOST:2376 \
-e DOCKER_TLS_VERIFY=1 \
-v /path/to/certs/:/certs/:ro \
journeyover/docker-autoheal:main
The required certificate files inside the container:
ca.pemclient-cert.pemclient-key.pemRefer to Docker's documentation for configuring TCP with mTLS.
services:
autoheal:
image: journeyover/docker-autoheal:main
restart: always
network_mode: none
environment:
- AUTOHEAL_CONTAINER_LABEL=autoheal-app
deploy:
replicas: 1
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
You can enable autoheal by choosing one of the following methods:
autoheal=true to your container labels.AUTOHEAL_CONTAINER_LABEL=all to monitor all running containers.AUTOHEAL_CONTAINER_LABEL with an existing container label that has the value true.Note: Ensure that your Docker images have a
HEALTHCHECKconfigured. See Docker's Healthcheck Reference for details.
| Label | Description |
|---|---|
autoheal.stop.timeout=20 | Overrides stop timeout (in seconds) for container restarts. |
| Variable | Description |
|---|---|
AUTOHEAL_CONTAINER_LABEL=autoheal | Monitors containers with the specified label set to true. |
AUTOHEAL_INTERVAL=5 | Checks container health every 5 seconds. |
AUTOHEAL_START_PERIOD=0 | Initial delay before the first health check (in seconds). |
AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 | Maximum time (in seconds) Docker waits before forcefully stopping a container. |
AUTOHEAL_ONLY_MONITOR_RUNNING=false | If true, only running containers are monitored (paused containers are ignored). |
AUTOHEAL_RESTART_THRESHOLD=5 | The maximum number of times a container can be restarted within the AUTOHEAL_RESTART_WINDOW before it is stopped. |
AUTOHEAL_RESTART_WINDOW=600 | The time window (in seconds) within which the restart count is tracked. If the container is restarted more than AUTOHEAL_RESTART_THRESHOLD times within this window, it will be stopped. |
DOCKER_SOCK=/var/run/docker.sock | Unix socket path for Docker API requests. |
CURL_TIMEOUT=30 | Maximum time (in seconds) for curl requests to the Docker API. |
WEBHOOK_URL="" | Sends a webhook notification if a container is restarted or fails to restart. |
To build and run locally:
docker buildx build -t autoheal .
docker run -d \
-e AUTOHEAL_CONTAINER_LABEL=all \
-v /var/run/docker.sock:/var/run/docker.sock \
autoheal
Content type
Image
Digest
sha256:d35179b41…
Size
22.4 MB
Last updated
3 months ago
docker pull journeyover/docker-autoheal