net core 5 application. I have added docker-file and running container which works fine. I have added health check into my application. In my application I have just added swagger and added sql health check. Below is my dockerfile
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /source
EXPOSE 80
EXPOSE 443
# copy csproj and restore as distinct layers
COPY *.sln .
COPY ConfigService/*.csproj ./ConfigService/
RUN dotnet restore
# copy everything else and build app
COPY ConfigService/. ./ConfigService/
WORKDIR /source/ConfigService
RUN dotnet publish -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "ConfigService.dll"]
When I run this application it works fine and when I open https://localhost:32788/swagger/index.html it works fine Also when I open https://localhost:32788/hc This is also works fine but when I open https://localhost:32788/hc-ui It shows me it shows Cannot assign requested address (localhost:32788) Below is my config in appsettings.json
"HealthChecksUI": {
"HealthChecks": [
{
"Name": "Health Check Service",
"Uri": "https://localhost:32788/hc"
}
],
"Webhooks": [
{
"Name": "",
"Uri": "",
"Payload": "",
"RestoredPayload": ""
}
],
"EvaluationTimeInSeconds": 10,
"MinimumSecondsBetweenFailureNotifications": 60
}
Below is config in Configure method
app.UseHealthChecks(path: "/hc", new Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecksUI(delegate (Options options)
{
options.UIPath = "/hc-ui";
});
I am not sure Why https://localhost:32788/hc-ui returns Cannot assign requested address (localhost:32788). Since I am running inside docker, Docker will not able to access port itself where it was running. Can someone help me to understand? Any help would be appreciated. Thank you