I have a .Net 3.1 API running as a Docker container (WSL2+ Linux Containers) on Windows 10. I am unable to access the API on any other ports except 5000 :
When i run the container as
docker run -d -p 8060:7110 golide/payapi:0.1.0
and try a GET in Postman to http://localhost:7110/weatherforecast I get "Unable to Connect" exception. But when i run the container as
docker run -d -p 5000:5000 golide/payapi:0.1.0
and try a GET in Postman to http://localhost:5000/weatherforecast I get the API response.
What am I missing regarding how Kestrel port binding works ?
My Dockerfile looks as follows :
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app
ENV ASPNETCORE_URLS http://+:5000
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "PaymentsAPI.dll"]
What additional configuration should I do (if any) in order to access the API on any other port ?