-
Notifications
You must be signed in to change notification settings - Fork 22
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
Visual Studio can't start containerized ASP.NET Core if Docker HealthChecks present whilst debugging #446
Comments
@zharchimage this is an issue with the debug support from VS. Currently there is no support for decencies and health checks when running from visual studio, although this is something we are working on improving. |
Hi @NCarlsonMSFT thanks for the answer, is there any workaround we can do to disable the fast mode for asp.net core containers? I have healthchecks in a custom SQLServer Image calling a shell script and works fine, so just wondering if there is something we can tweak in the
But it is not ideal as WebApplication2 often fails as depends in WebApplication1 finishing first doing some warmup work. |
The only other work-around I can suggest is to use the label com.microsoft.visual-studio.project-name to empty string to disable debugging in the dependent service which works around the issue, but then requires attaching to debug the 2nd service. |
Thanks, will try that for now. |
Commenting in here as this is something that's also causing me issues. Spent too long trying to figure out what was wrong too. For reference, I have two containers, A and B. B depends on A. Both are ASP.Net applications. When the depends_on is commented out in docker-compose for container B, both containers spin up simultaneously (causing issues with B) however the health check for container A passes, and shows healthy (showing the health check itself is fine). When depends_on is uncommented, it causes container A to fail to start up. The curl request fails saying the connection was refused and the container is left in an unhealthy state. This only happens when running in Visual Studio. |
@zharchimage, @WMTaylor2Degrees <PropertyGroup>
<DependencyAwareStart>true</DependencyAwareStart>
</PropertyGroup> If you can, please try out the preview and let me know if you're unblocked now! |
I'm building 2 ASP.NET Core Web API services containerized with Docker,
WebApplication1
andWebApplication2
.WebApplication2
depends onWebApplication1
that is why inWebApplication1
, I have an endpoint exposed for the HealthCheck that docker compose will implement forWebApplication1
:With Dockerfile
Startup code and Dockerfile for
WebApplication2
is exactly the same. This is the Docker Compose file:Notice this line test: curl http://localhost:8080/health1 || exit 1 is the code that should be marking
WebApplication1
as healthy soWebApplication2
can start. When I debug the docker compose orchestration, it fails:Running
results in this error:
curl: (7) Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server
I placed a breakpoint in Program.cs from
WebApplication1
and it doesn't get started under this configuration, but if I comment the healthcheck code from the compose file it works as expected. Weirdly enough if I do a docker compose up --build, it works properlyMy first thoughts were that should be something with the Visual Studio Docker tools configuration in Debug mode, it was suggested in other StackOverFlow posts to add this:
But doesn't work either. Any ideas what is going wrong with the health checks?
I attach a working project DockerWebApiHealthChecksBug.zip so it can be easily tested
The text was updated successfully, but these errors were encountered: