Sign inSign up

sushibox/autoheal

By sushibox

Updated about 2 years ago

Image
0

268

sushibox/autoheal repository overview

Docker Autoheal 2

A better Autoheal

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:

Logging

Added a logging mechanism to append log messages to the specified LOG_FILE for future reference.

Notification

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.

Container Exclusion

Added support for excluding specific containers from autohealing using the EXCLUDED_CONTAINERS environment variable.

Scheduling

Introduced time window configuration with the SCHEDULE_START and SCHEDULE_END environment variables for enabling or disabling autohealing based on a predefined schedule.

How to Use

UNIX Socket Passthrough
    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
TCP Socket
    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
Options

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.

Environment Variable Defaults

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.

Tag summary

Content type

Image

Digest

sha256:54ec9bb04

Size

6.3 MB

Last updated

about 2 years ago

docker pull sushibox/autoheal