Im trying to dockerize an ASP.NET application, however I am having some issues with the health checks, I have a simple program like
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.MapHealthChecks( "/health" );
app.Run();
And when I run it locally, it all works fine and I can see that the healthchecks return healthy, however when I run it in a docker container with the following docker-compose
version: '3.2'
services:
asp-service:
image: bitnami/dotnet-sdk
working_dir: /app
command: "./run.sh"
volumes:
- "./:/app:rw"
ports:
- 8080:8080
healthcheck:
test: curl --fail https://asp-service:8080/health || exit 1
interval: 30s
timeout: 30s
retries: 3
Where run.sh is a simple script which just runs dotnet run
I can see the service runs fine, however when I run docker ps
I can see the status returns health: unhealthy