.NET 9 and latest DOcker Desktop on Windows 11 Pro -> Unable to call destination container by name(Aliases Network Name in Docker) anymore, have to use 'host.docker.internal:PortNumber'
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Deploy latest .NET 9 APIs with YARP setting calling the container by name within the URL with portnumbers, the below doesn't work anymore:
"Clusters": {
"addresses-cluster": {
"Destinations": {
"addresses-cluster/destination1": {
"Address": "http://address.api:5563"
}
}
},
"test-cluster": {
"Destinations": {
"test-cluster/destination1": {
"Address": "http://testapi:5006"
}
}
}
}
This works with the latest .NET 9 with latest Docker Desktop:
"Clusters": {
"addresses-cluster": {
"Destinations": {
"addresses-cluster/destination1": {
"Address": "http://host.docker.internal:5563"
}
}
},
"test-cluster": {
"Destinations": {
"test-cluster/destination1": {
"Address": "http://host.docker.internal:5006"
}
}
}
}
Got Exceptions? Include both the message and the stack trace -->
Further technical details
- .NET 9 latest .Net core LINUX on Docker Desktop running WSL2.
- Windows 11 Pro.
- Latest Docker Desktop latest
- VS2022 Community latest.
Can you share how you have docker configured (yarp & other services)?
YARP doesn't do anything special re: docker. If the host is reachable it'll work, so if it's not it's likely an issue in your docker setup.
@MihaZupan Running latest Docker desktop and .NET 9:
docker-compose.yml file below:
`services:
identity.customer.api: image: ${DOCKER_REGISTRY-}identitycustomerapi container_name: identity.customer.api build: context: . dockerfile: src/Identity.Customer.API/Dockerfile ports: - 5553:5553 - 5554:5554 networks: - proxybackend
addresses.api: image: ${DOCKER_REGISTRY-}addressesapi build: context: . dockerfile: src/Addresses.API/Dockerfile ports: - 5563:5563 - 5564:5564 networks: - proxybackend
networks: proxybackend: name: proxybackend driver: bridge`
docker-compsose.override.yml
`services: identity.customer.api: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_HTTP_PORTS=5553 - ASPNETCORE_HTTPS_PORTS=5554 ports: - "5553" - "5554" volumes: - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro - ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro
addresses.api: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_HTTP_PORTS=5563 - ASPNETCORE_HTTPS_PORTS=5564 ports: - "5563" - "5564" volumes: - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro - ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro`
Dockerfile for my API Identity Yarp service:
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base USER app WORKDIR /app EXPOSE 5553 EXPOSE 5554
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["Identity.Customer.API/Identity.Customer.API.csproj", "Identity.Customer.API/"] RUN dotnet restore "./Identity.Customer.API/Identity.Customer.API.csproj" COPY . . WORKDIR "/src/Identity.Customer.API" RUN dotnet build "./Identity.Customer.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./Identity.Customer.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Identity.Customer.API.dll"]
Docker desktop (latest):
Could you just be looking at a typo?
address.api:5563 => addresses.api:5563
Could you just be looking at a typo?
address.api:5563=>addresses.api:5563
@MihaZupan Thanks for noticing, but I recently updated everything to 'addresses.api'.
This is currently working fine:
This is not:
The Error returned in postman for above Address destination cluster:
Error: getaddrinfo ENOTFOUND addresses.api
- I also reinstalled docker on my local machine, very weird.
Just a guess, have you tried not including dots in your service name?
E.g. name the service addresses-api instead?
-
Milan .NET youtube start uses dots with .NET 8 and it works: https://youtu.be/UidT7YYu97s?si=SMKQ2rsaDXE9H9bp&t=615
-
I have tried using dashes 'Error: getaddrinfo ENOTFOUND addresses-api' same error in postman and within insomnia app (like postman).
Can anyone else test this bug? Should we make it a new Yarp Bug with latest .NET 9 ?
I'm not familiar with the video. When using YARP and/or Postman, are you using it from inside Docker? It's expected that DNS resolution will differ from outside the network such that services can't be resolved.
Should we make it a new Yarp Bug with latest .NET 9 ?
I don't understand the question?
@MihaZupan Is there a good working YARP .NET 9 Example which runs with docker-compose on Docker desktop? url?
This was resolved in in here:
https://github.com/dotnet/yarp/issues/2735
Done. Not a bug.
Thanks for assistance.