dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 475 forks source link

Unable to connect to container running under Rancher Desktop when using Aspire 9 #6735

Closed aDisplayName closed 2 days ago

aDisplayName commented 2 days ago

Is there an existing issue for this?

Describe the bug

With the exact the same AppHost code, the connection to container cannot be made in .NET 9, but runs normal in .NET 8.

main code:

var builder = DistributedApplication.CreateBuilder(args);
var container = builder.AddContainer("web", "nginx", "1.27.2")
    .WithEndpoint(targetPort: 80);

builder.Build().Run();

Expected Behavior

Container resource running under Rancher Desktop can be reached from the host.

Steps To Reproduce

Result from .NET 8 version

Code example: https://github.com/aDisplayName/bugsamplecode/tree/main/20241119/net8

When running the .net 8 version, this is what shown in Rancher Desktop UI Image

There are two endpoints listed under the details panel Image

The curl to http://127.0.0.1:32773 and http://localhost:64544 returns the nginx welcome page correctly on Windows Terminal and Webbrowser running in Windows.

The curl to http://localhost:32773 from wsl Terminal returns the nginx welcome page correctly.

The curl to http://localhost:64544 from wsl Terminal:

$ curl http://localhost:64544 -v
* Host localhost:64544 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:64544...
* connect to ::1 port 64544 from ::1 port 51014 failed: Connection refused
*   Trying 127.0.0.1:64544...
* connect to 127.0.0.1 port 64544 from 127.0.0.1 port 34398 failed: Connection refused
* Failed to connect to localhost port 64544 after 0 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to localhost port 64544 after 0 ms: Couldn't connect to server
Result from .NET 9 version

Code Example: https://github.com/aDisplayName/bugsamplecode/tree/main/20241119/net9

When running the .net 9 version, This is what shown in Rancher Desktop UI Image

there are two endpoints listed under the details panel Image

The curl to http://localhost:63440 from Windows Terminal:

PS > curl http://localhost:63440 -v
* Host localhost:63440 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:63440...
*   Trying 127.0.0.1:63440...
* Connected to localhost (127.0.0.1) port 63440
> GET / HTTP/1.1
> Host: localhost:63440
> User-Agent: curl/8.9.1
> Accept: */*
>
* Empty reply from server
* shutting down connection #0
curl: (52) Empty reply from server

The curl to http://localhost:63440 from wsl terminal:

$ curl http://localhost:63440 -v
* Host localhost:63440 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:63440...
* connect to ::1 port 63440 from ::1 port 48270 failed: Connection refused
*   Trying 127.0.0.1:63440...
* connect to 127.0.0.1 port 63440 from 127.0.0.1 port 45064 failed: Connection refused
* Failed to connect to localhost port 63440 after 0 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to localhost port 63440 after 0 ms: Couldn't connect to server

The curl to http://127.0.0.1/32772 from Windows Terminal:

PS > curl http://127.0.0.1:32772 -v
*   Trying 127.0.0.1:32772...
* Connected to 127.0.0.1 (127.0.0.1) port 32772
> GET / HTTP/1.1
> Host: 127.0.0.1:32772
> User-Agent: curl/8.9.1
> Accept: */*
>
* Recv failure: Connection was aborted
* closing connection #0
curl: (56) Recv failure: Connection was aborted

The curl to http://127.0.0.1/32772 from wsl terminal:

$ curl http://127.0.0.1:32772 -v
*   Trying 127.0.0.1:32772...
* Connected to 127.0.0.1 (127.0.0.1) port 32772
> GET / HTTP/1.1
> Host: 127.0.0.1:32772
> User-Agent: curl/8.5.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection
curl: (56) Recv failure: Connection reset by peer

Exceptions (if any)

No response

.NET Version info

Aspnet core: 9.0 / 8.0 Aspire.Hosting.AppHost: 9.0 / 8.2.2

Anything else?

Rancher Desktop 1.16.0 Windows 11 Enterprise 23H2, Windows Feature Experience Pack 1000.22700.1041.0 WSL Ubuntu 24.04.1 LTS

joperezr commented 2 days ago

Hello, thanks for the submission @aDisplayName . We don't yet support Rancher, but we are tracking adding support in #6002. I'm closing this as a dupe for now to track adding support there, but feel free to reopen if you have any follow up questions.