I have a .NET application running in DOCKER and need to configure container health checks. Currently I see a few options:
Option 1
Install curl in the runtime image.
Use Docker HEALTHCHECK with a command such as:
HEALTHCHECK CMD curl -f http://localhost:8080/health/ready || exit 1
Option 2
Use an image such as aspnet:10.0-alpine that already contains wget.
Use wget for the health check.
Option 3
Create a custom executable or .NET program that calls the application’s health endpoint and returns an appropriate exit code.
Use that executable in the Docker HEALTHCHECK.
My concern is that installing additional tools such as curl or wget increases the image surface area and may introduce additional security considerations.
Is there a recommended or more idiomatic approach for health checks in .NET containers that avoids adding extra packages while still working well with Docker and orchestrators such as Kubernetes?
How are others handling health checks in production .NET containers?