Monitor and restart unhealthy docker containers.
latest
a) Apply the label autoheal=true to your container to have it watched.
autoheal=true
b) Set ENV AUTOHEAL_CONTAINER_LABEL=all to watch all running containers.
AUTOHEAL_CONTAINER_LABEL=all
c) Set ENV AUTOHEAL_CONTAINER_LABEL to existing label name that has the value true.
AUTOHEAL_CONTAINER_LABEL
true
Note: You must apply HEALTHCHECK to your docker images first. See https://docs.docker.com/engine/reference/builder/#/healthcheck for details.
HEALTHCHECK
AUTOHEAL_CONTAINER_LABEL=autoheal AUTOHEAL_INTERVAL=5
docker build -t autoheal . docker run -d \ -e AUTOHEAL_CONTAINER_LABEL=all \ -v /var/run/docker.sock:/tmp/docker.sock \ autoheal