Docker Autoheal is a tool that monitors and restarts unhealthy Docker containers. It ensures that your containers are always running in a healthy state by detecting any failures and automatically restarting them.
The script in this version of Autoheal has been improved to incorporate changes such as:
Added a logging mechanism to append log messages to the specified LOG_FILE for future reference.
Implemented email notifications using the mail command and the NOTIFICATION_EMAIL environment variable. Also added Discord webhook notifications using the DISCORD_WEBHOOK_URL environment variable.
Added support for excluding specific containers from autohealing using the EXCLUDED_CONTAINERS environment variable.
Introduced time window configuration with the SCHEDULE_START and SCHEDULE_END environment variables for enabling or disabling autohealing based on a predefined schedule.
docker run -d \
--name autoheal \
--restart=always \
-e AUTOHEAL_CONTAINER_LABEL=all \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/localtime:/etc/localtime:ro \
docker.io/sushibox/docker-autoheal:latest
docker run -d \
--name autoheal \
--restart=always \
-e AUTOHEAL_CONTAINER_LABEL=all \
-e DOCKER_SOCKET=tcp://HOST:PORT \
-v /etc/localtime:/etc/localtime:ro \
docker.io/sushibox/docker-autoheal:latest
Docker Autoheal provides several options for customization:
a) Apply the label autoheal=true to the containers you want to monitor and restart.
b) Set the environment variable CONTAINER_LABEL=all to monitor all running containers.
c) Set the environment variable CONTAINER_LABEL to the name of an existing label that has the value true.
Note: Before using Docker Autoheal, you must apply a HEALTHCHECK to your Docker images. Refer to the Docker documentation for more details. Additionally, you can configure TCP with mTLS by following the instructions in the Docker documentation.
Docker Autoheal includes the following environment variables with their default values:
CONTAINER_LABEL=autoheal
INTERVAL=5 # Check every 5 seconds
START_PERIOD=0 # Wait 0 seconds before the first health check
DEFAULT_STOP_TIMEOUT=10 # Docker waits a maximum of 10 seconds for a container to stop before killing it during restarts (container-specific timeout can be set via label, as explained below)
DOCKER_SOCKET=/var/run/docker.sock # Unix socket for curl requests to Docker API
CURL_TIMEOUT=30 # Maximum timeout in seconds for curl requests to Docker API
LOG_FILE=/var/log/autoheal.log # Path to the log file
[email protected] # Email address for notifications
DISCORD_WEBHOOK_URL= # Webhook URL for sending Discord notifications (leave empty if not using Discord notifications)
Feel free to modify these environment variables according to your needs.
Content type
Image
Digest
sha256:54ec9bb04…
Size
6.3 MB
Last updated
about 2 years ago
docker pull sushibox/autoheal