The reason I want to change it is because at the moment, when I connect via postman to https://localhost:59541, I get Error: Client network socket disconnected before secure TLS connection was established
If you try it and it gives you an error message or does not work, then it is probably not possible I still don’t understand that port configuration but I ignore that for the moment since it may not be relevant. I assume you know what you are doing. I have never tried 0 as a target port. I googled it and if I understand it, this is a special port to tell the system to find a suitable port. I don’t know if it is possible to use it as a target port or just for a listening address (I guess this is the case), but I would not do it anyway. When you run a container, you want to know what service is listening on what port. And since it is inside a container, you don’t even need to worry about that a port is already used by an other service.
So since I can’t do more than check that configuration myself on my machine, which you can do too, I leave it to you. If you get an arror message that you don’t understand, we can try to explain that to you.
If the error message in the title is the result of your test using port 0 as target, than probably this is the answer.
Sorry, I forgot the title when I came back to to topic
This is the strangest thing. This is my Dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
#Add the nuget line if building locally
COPY ["../NuGet.Config", "."]
COPY ["AppOne.Api/AppOne.Api.csproj", "AppOne.Api/"]
COPY ["AppOne.ClassLibrary/AppOne.ClassLibrary.csproj", "AppOne.ClassLibrary/"]
COPY ["AppOne.Data/AppOne.Data.csproj", "AppOne.Data/"]
COPY ["AppOne_AS.Connect/AppOne_AS.Connect.csproj", "AppOne_AS.Connect/"]
RUN dotnet restore "AppOne.Api/AppOne.Api.csproj"
COPY . .
RUN dotnet build "AppOne.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AppOne.Api.csproj" -c Release -o /app/publish
FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AppOne.Api.dll"]
In the referred tpic that is not port 0, just the IP address to listen on every available IP addresses. I would understand that, but you want to use port 0 as target port.
HTTPS is not just a choice that you make and tell the server to listen on HTTPS protocol. You need to provide TLS certificates. This is true with and without Docker too. I don’t see certificates in your shared codes.
Again. I don’t see any certificate settings in your code.
Since I am not a ASPNET developer, I have no idea how TLS works with ASPNET. If you can make it work without Docker or at least you can enter the container and check the HTTPS acces from inside the container without error, than we can try to figure out what is required to make it work from outside.