Checks health of a HTTP server. Makes a request, prints the result and exits with code.
456
Checks health of a HTTP server. Makes a request, prints the result and exits with zero (success) or non-zero (failure) Suitable for HEALTHCHECK in Dockerfile or healthcheck in docker-compose.yml. Maintained on GitHub.
❯ healthchk https://github.com
status: 200, type: text/html; charset=utf-8, size: 229912 bytes, duration: 2042 ms
An example of Dockerfile:
FROM prantlf/healthchk as healthchk
FROM ...
COPY --from=healthchk /healthchk /
...
HEALTHCHECK --interval=1m CMD /healthchk http://localhost/ping || exit 1
An example of docker-compose.yml:
services:
service:
healthcheck:
test: ["CMD", "/healthcheck", "http://localhost/ping"]
interval: 1m
restart: unless-stopped
usage: healthchk [option ...] <url>
options:
-m <method> HTTP method to use (default: GET)
-t <seconds> connection timeout (default: 30 seconds)
-R disallow redirects (default: allowed)
-s print nothing on success (default: no)
-v print the response body too (default: no)
In lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code.
Copyright (C) 2024 Ferdinand Prantl
Licensed under the MIT License.
Content type
Image
Digest
sha256:b380d075e…
Size
420.9 kB
Last updated
over 2 years ago
docker pull prantlf/healthchk