docker-maven-plugin
docker-maven-plugin copied to clipboard
healthCheck not working
Description
When both healthcheck and wait/healthy are configured, I get this error: “Can not wait for healthstate of [busybox:latest] "healthybox1". No HEALTHCHECK configured.” I don't include code snippets because this happens even if I run the official sample project (linked below). If I only have a healthCheck section defined, without wait/healthy then the container starts but the healthcheck is missing so the error seems to indicate the true issue correctly - somehow the healthcheck is not created from the definition.
Info
- docker-maven-plugin version : 0.40.1
- Maven version (
mvn -v
) : 3.6.3 - Docker version : 4.10.0 (82025)
- If it's a bug, how to reproduce : run sumple project
- Sample project : [GitHub Clone URL]
Sounds indeed like a bug. Could you look into the generated Dockerfile, i.e. target/docker/imagename/build
? Actually when I run it in samples/healtchecks
, the HEALTHCHECKS are generated as requested:
FROM busybox
HEALTHCHECK CMD curl -f http://localhost/ || exit 1
CMD sleep 2
Yes, that's the outcome of the docker:build but can you actually run docker:start with success?
You are right, the samples are broken.
The samples have probably only been created to check whether the images are probably built, not running. E.g. in busybox, no HTTP server is running, so the check with curl will always fail.
Also, the timing parameters are not well chosen. I.e., a sleep 2
is far too small. According to the Docker documentation, the health check by default only kicks in after 30s, so any other timeout that is shorter will prevent the health check to run.
The
So, for now you have several options:
- Reduce the time until the first health check is run by Docker via the option
interval
(see https://dmp.fabric8.io/#build-healthcheck). Set this shorter than the 10s timeout for the<wait>
- Increase the timeout for
<wait>
by setting e.g.<time>35000</time>
. That would be longer than the first check to start.
But as mentioned, there are issues and possibilities to improve:
- Increase the timeout for
<wait>
automatically to be larger than theinterval
of a possible<healthcheck>
condition (and larger than 30s if no interval is provided) - Allow
<time>
to be specified with a unit like other timing parameters (providing it as milliseconds does not align with e.g. second based numbers used elsewhere. - Fix the samples that they use real health check that succeed (e.g. just
exit 0
) or failed (eg.exit 1
) and tune the parameters accordingly.
I encounter the same issue "No HEALTHCHECK configured". The proposed options did not make it work for me. I cannot even get the linked samples to compile using mvn install
(and after doing a successful docker login
):
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.40.3:start (start) on project dmp-sample-healthcheck: I/O Error: Unable to pull 'busybox1:latest' : {"message":"pull access denied for busybox1, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"} (Not Found: 404) -> [Help 1]