Skip to content
Monitor and restart unhealthy docker containers.
Branch: master
Clone or download
Latest commit 62f7279 Feb 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore fix: add in gitignore Feb 26, 2019
.gitlab-ci.yml Added gitlab-ci.yml to be able to build the containers in gitlab. Aug 19, 2018
.travis.yml Added gitlab-ci.yml to be able to build the containers in gitlab. Aug 19, 2018
Dockerfile
LICENSE feat: add licence Oct 2, 2018
README.md Add global and per container stop timeouts ; minor doc fixes Feb 25, 2019
build.sh
docker-entrypoint

README.md

docker-autoheal

Monitor and restart unhealthy docker containers. This functionality was proposed to be included with the addition of HEALTHCHECK, however didn't make the cut. This container is a stand-in till there is native support for --exit-on-unhealthy https://github.com/docker/docker/pull/22719.

Supported tags and Dockerfile links

How to use

docker run -d \
    --name autoheal \
    --restart=always \
    -e AUTOHEAL_CONTAINER_LABEL=all \
    -v /var/run/docker.sock:/var/run/docker.sock \
    willfarrell/autoheal

a) Apply the label autoheal=true to your container to have it watched.

b) Set ENV AUTOHEAL_CONTAINER_LABEL=all to watch all running containers.

c) Set ENV AUTOHEAL_CONTAINER_LABEL to existing label name that has the value true.

Note: You must apply HEALTHCHECK to your docker images first. See https://docs.docker.com/engine/reference/builder/#healthcheck for details.

ENV Defaults

AUTOHEAL_CONTAINER_LABEL=autoheal
AUTOHEAL_INTERVAL=5   # check every 5 seconds
AUTOHEAL_START_PERIOD=0   # wait 0 seconds before first health check
AUTOHEAL_DEFAULT_STOP_TIMEOUT=10   # Docker waits max 10 seconds (the Docker default) for a container to stop before killing during restarts (container overridable via label, see below)
DOCKER_SOCK=/var/run/docker.sock   # Unix socket for curl requests to Docker API
CURL_TIMEOUT=30     # --max-time seconds for curl requests to Docker API

Optional Container Labels

autoheal.stop.timeout=20        # Per containers override for stop timeout seconds during restart

Testing

docker build -t autoheal .

docker run -d \
    -e AUTOHEAL_CONTAINER_LABEL=all \
    -v /var/run/docker.sock:/var/run/docker.sock \
    autoheal                                                                        
You can’t perform that action at this time.