aspire: Container to host networking not working with podman
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Something doesn’t seem right with how Aspire expects dapr sidecars to be visible for containers.
My dapr publisher is unable to reach the sidecar that Aspire configures for me:
io.netty.channel.ConnectTimeoutException: connection timed out: host.containers.internal/169.254.1.2:38047
(this exception means that my extension was working up until the point it tries to reach out over the network)
Expected Behavior
I expect my container to be able to see the dapr sidecar.
Steps To Reproduce
Regardless of whether I use DOTNET_ASPIRE_CONTAINER_RUNTIME=podman, or not, along with the following configuration:
var daprDefaults = new DaprSidecarOptions
{
RuntimePath = "./resources",
};
builder
.AddKeycloak("auth", 8080, adminUser, adminPassword)
.WithDataVolume()
.WithBindMount("./resources/keycloak-dapr-publisher-0.0.1-all.jar", "/opt/keycloak/providers/keycloak-dapr-publisher-0.0.1-all.jar")
.WithDaprSidecar(daprDefaults)
;
Exceptions (if any)
No exceptions are reported by Aspire, although in my specific scenario above, the code depending on the dapr sidecar is unable to reach it, and ends up throwing an exception.
I know for a fact that this code works in a manually assembled scenario, so it’s not a bug in that code. You can also see that it specifically fails during resolution of the GRPC endpoint that Aspire injects on behalf of the dapr sidecar.
.NET Version info
All 9s!
Anything else?
In this case, I haven’t done any network level customization, so Aspire is totally in the drivers seat. But it’s still difficult to tell when host.containers.internal is going to work and when it won’t.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 33 (16 by maintainers)
I want this comment in known issues @IEvangelist.
@danegsta if we turn the proxy off this should “work” in this scenario right?
The behavior of host.docker.internal/host.containers.internal depends on the specific OS and container runtime implementation.
With Linux, the host gateways are implemented via a custom network interface, which means traffic from Docker networking is technically a separate network than the host machine network. We made the decision early in Aspire to run our proxies bound to localhost in order to limit traffic to the local machine, but this means that they can’t accept traffic routed via container host gateways. On Linux, any host ports accessible from Docker/Podman need to be either bound to all network interfaces (0.0.0.0) or specifically to the IP of the container gateway network interface.
Running on Windows, the problem is even more complicated, as Docker/Podman are running in a WSL instance, which adds an additional layer of network abstraction. The container host gateway networks route to WSL network interfaces, not to the default Windows network interface. Effectively the container networks can only access ports bound from the WSL side of the network. MacOS has similar behavior since the container runtime is running in a VM which has a similar level of network isolation as WSL on Windows.
Docker Desktop is currently the one scenario where things just work when routing traffic to the local network, as Docker Desktop implements the container host gateway in such a way that it directly routes traffic to localhost on the host machine (even when running in WSL on Windows) rather than via a separate network interface.
The port is correct. Read that document I linked, the proxy should be linked to the target (there’s a proxy by default)
Sadly due to their licensing, that’s just not an option for me anymore.
Anything else?