-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run health check ui in docker #692
Comments
Is someone looking into this issue? Thank you |
Hi @CarlosLanderas can you take a look on this! |
@niranjan2020 you are exposing ports 80 and 443 in the container. When the UI is checking endpoints it will use those internal ports not 32788 that is probably your mapped development environment port. (https://localhost:32788/hc) Could you show me your docker-compose or docker run command to see how you start the container? Thanks |
Thanks @CarlosLanderas for your response. I have not created docker compose file and I directly run from visual studio 2019. I select docker instead of IISExpress and run. |
Try setting the remote healthcheck endpoint to http://localhost/hc |
@CarlosLanderas I added http://localhost/hc and got error Cannot assign requested address (localhost:32788) |
Can you show your launch settings.json? |
|
@CarlosLanderas I changed little bit dockerfile as below copy csproj and restore as distinct layersCOPY .sln . copy everything else and build appCOPY ConfigService/. ./ConfigService/ final stage/imageFROM mcr.microsoft.com/dotnet/aspnet:5.0 Then I build using Then run using and added "Uri": "http://localhost:5002/hc" in appsettings.json. But still gave me same error Cannot assign requested address (localhost:5002) Since I am using .Net 5. Is this compatible issue? |
@CarlosLanderas Just want to know If there is any fix? Thank you |
@niranjan2020 the uri http://localhost:5002/hc is not accessible inside docker. That is a port mapped in your host. Docker will use port 80 internally |
I added "Uri": "https://localhost:80/hc" but it shows The SSL connection could not be established, see inner exception. |
You are trying to use https in port 80. Use http instead |
@CarlosLanderas I added http://localhost:80/hc in my appsettings.json but started getting error Cannot assign requested address (localhost:32770)
|
Niranjan, try launching your image outside of visual studio, just with a console. The problems you are having come from launching this with VS. Can you paste the contents of your launchSettings.json? |
@CarlosLanderas I'm also having issues getting the UI to work when running in docker; the internal health is not exposed to the docker host on the port 80/443 calling the endpoint with the exposed port works as you would expect, however the UI client fails to call the endpoint as defined in the json on the correct port? (internal to docker) Also when using https in docker the client is reporting certificate issues; using http the causes a complete different set of problems as the code is using http - redirect to https |
Please paste your code so we can try to help. We run HealthChecks UI in containers in a daily basis, so this might be configuration. |
@CarlosLanderas thanks I have been able to resolve the issue by adding the hostname setting to the docker file; the services are now addressable via http://[hostname]/health |
@3GDXC can you explain exactly what you did please? |
+1, same proleme here. Can you explain your fix @3GDXC |
I manage to solve it using setup.AddHealthCheckEndpoint(group, $"http://{Dns.GetHostName()}/healthchecks-{group}"); and when you launch your docker, you need to specify a hostname. It can be anything. The library is great except that lol. |
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
app.UseHealthChecks(path: "/hc", new Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecksUI(delegate (Options options)
{
options.UIPath = "/hc-ui";
});
The text was updated successfully, but these errors were encountered: