From cf6d74a2be829bcbfde3799bad0a824a83b4b49a Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 24 Feb 2020 22:39:24 -0500 Subject: [PATCH] Improve healthcheck responsiveness. By default, dig will retry 2 times (for a total of 3 attempts) to get a response back. Each attempt defaults to 5 seconds. Before this change, a single docker healtcheck failure would really mean three failures and would take a total of 15 seconds before failing. By default, docker healthchecks will retry 3 times before considering a service unhealhy (with a 30 second interval). Combined with dig retries, this means it would take a total of 9 failed DNS responses before it considers the pihole to be unhealthy. Combining the retry between dig and docker, dig considers it a success if even 1/3 responses are recieved - and docker considers it a success if only 1/3 of those successes are successful. I'm not great at math - and order does make a difference - but I think that means as long as 1/9th of DNS queries are being answered - then docker thinks its healthy. Anyways, long story sort, dig doesn't need to have its own retry logic since docker already has a configuarable retry. I also disable recurse since the goal is to test this specific instance. Also removed duplicate import statement. Signed-off-by: Daniel --- Dockerfile.py | 1 - Dockerfile.template | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile.py b/Dockerfile.py index 91f808aba..c0c271765 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -17,7 +17,6 @@ """ -from docopt import docopt from jinja2 import Environment, FileSystemLoader from docopt import docopt import os diff --git a/Dockerfile.template b/Dockerfile.template index c49209287..cce6af46c 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -44,6 +44,6 @@ LABEL image="{{ pihole.name }}:{{ pihole.version }}_{{ pihole.arch }}" LABEL maintainer="{{ pihole.maintainer }}" LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 +HEALTHCHECK CMD dig +norecurse +retry=0 @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"]