I am trying to run a unit test in a .net core WebApi.
When i try to create a image out of the solution the unit test fail, but running on IDE unit test works.
I get this error building the image : “Cannot assign requested address (localhost:5000)”
The base URL for Web Api is set as “localhost:5000”.
Below is dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY Testing.sln ./
COPY ./Testing/ ./Testing
COPY ./TestProject2/ ./TestProject2
RUN dotnet restore Testing.sln
RUN dotnet test ./TestProject2/TestProject2.csproj
FROM build AS publish
RUN dotnet publish "Testing.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_URLS=http://+:5000 DOTNET_RUNNING_IN_CONTAINER=true
ENTRYPOINT ["dotnet", "Testing.dll"]