Docker Container Healthcheck



If you want to use the healthcheck feature for a container. You can use curl for that.

curl -fs http://localhost:8008/health


user@XX:~$ curl --help
Usage: curl [options...] <url>
 -f, --fail          Fail silently (no output at all) on HTTP errors
 -s, --silent        Silent mode


You need to enable it via Dockerfile HEALTHCHECK.

HEALTHCHECK --interval=10s --timeout=5s \
  CMD curl -fs http://localhost:8008/health || exit 1

Ad hock


--health-cmd		Command to run to check health
--health-interval		Time between running the check (ms|s|m|h) (default 0s)
--health-retries		Consecutive failures needed to report unhealthy
--health-start-period		API 1.29+
Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
--health-timeout		Maximum time to allow one check to run (ms|s|m|h) (default 0s)
Written on November 10, 2021 at 17:10

Last but not least

If the post is updated, the creation date, will be pushed. So it might happend, you see an existing page back on frontpage. I think, this approach is valid, so wrong information or gained information is covered. But if I am going to write a new part of topic, I might include an updated link to the new post.