A small-as-possible binary for performing docker health checks against an HTTP endpoint
358
This project is intended as a lightweight binary that can be included in a docker image for health checks. The latest image size is included in the badge above.
It expects two arguments, a host address and an HTTP endpoint.
healthcheck localhost:80 /ok
Healthcheck makes a GET request to the provided host and endpoint and exits with code 0 if it receives a response code of 200 OK. On any other error, it exits with code 1.
nginx.conf
http {
server {
listen 8080;
location /ok {
return 200;
}
}
}
Dockerfile
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.cof
COPY --from=subtlespeudonym/healthcheck:latest /healthcheck /healthcheck
EXPOSE 8080
HEALTHCHECK CMD healthcheck localhost:8080 /ok
To get the smallest, static binary and the same one included in the docker image:
make release
There are, however, a few other options to building this project:
# best performance, large binary, dynamically linked
cargo build
# smallest binary, dynamically linked
cargo build --release
# statically linked
cargo build --release --target x86_64-unknown-linux-musl
Content type
Image
Digest
sha256:bbdb9924f…
Size
47.2 kB
Last updated
about 4 years ago
docker pull subtlepseudonym/healthcheck