Hi,
i have a docker-compose file with several simple http healthchecks like these:
healthcheck:
test: "curl --fail http://localhost:8080/health/ || exit 1"
but all of them report ‘unhealthy’
Am I missing something here?
Share and learn in the Docker community.
Hi,
i have a docker-compose file with several simple http healthchecks like these:
healthcheck:
test: "curl --fail http://localhost:8080/health/ || exit 1"
but all of them report ‘unhealthy’
Am I missing something here?
Hello Jack,
a working healthcheck for my NginX-container looks this way:
healthcheck:
test: service nginx status || exit 1
interval: 15s
timeout: 3s
retries: 2
But even if I remove the lines starting with interval
, timeout
and retries
it is working as expected - container marked as healthy
after some time.
I have successfully tested my Nginx-container (where curl
is available) with this healthcheck
-line:
healthcheck:
test: "curl --silent --fail http://localhost/ > /dev/null || exit 1"
So I guess the problem is somewhere else.
curl
is available within the container.curl...
-command at the container’s shell? What is the exit-code of your curl
-command if you run it at the container’s shell? The last-command’s exit-code can be printed with echo $?
I found the cause(s) and now all healthcheck are green:
This answer helped me a lot, I was using an Alpine image. By default ‘curl’ isn’t installed, changing into a wget request fixed the issue.