So I have this ASP.NET Core app I recently dockerized. It works fine in my local machine, it runs when I push it into AWS App Runner, except when I want to make a DB call, it is then when I experience this exception:
ExtendedSocketException: Resource temporarily unavailable System.Net.Dns.GetHostEntryOrAddressesCore(string hostName, bool justAddresses)
The exception isn't too relevant to .Net or C# knowledge, what matters is what it tells us, it says that there are no sockets available inside the container.
I am fairly new to containerization and hosting said containers in AWS, having worked on EC2 only before.
My guess is that the container running in AWS App Runner has limitations on the networking that aren't present in how Docker Desktop runs the container when I hit the run button.
Is there any way I can configure networking to be more open in AWS App Runner? Be it a configuration in the service or through the Dockerfile.
My Dockerfile is as follows, for reference:
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "LeadDog.Web/LeadDog.Web.csproj"
COPY . .
WORKDIR "/src/LeadDog.Web"
RUN dotnet build "LeadDog.Web.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "LeadDog.Web.csproj" -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
FROM base AS final
ENV ASPNETCORE_ENVIRONMENT=Development
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LeadDog.Web.dll"]
Edit:
This was the closest I got to an answer, but my lack of expertise with Docker still leaves me with questions, since I don't know if I can set a network mode from the Dockerfile or if I can configure a network mode in AWS App Runner.
Thanks in advance,