I am trying to debug my blazor server app application by running it into docker container. My application is using AD B2C which is configured for 4100 Host_port. I have created my dockerfile which is creating image and starting docker container as well. The problem is I'm trying to define Host_Port in dockerfile so that docker run command can pick it up form dockerfile. Firstly, Is it possible? If yes then how?
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["TS.UI/TS.UI.csproj", "TS.WebUI/"]
COPY ["TS.Common/TS.Common.csproj", "TS.Common/"]
COPY ["TS.Lab/TS.Lab.csproj", "TS.Lab/"]
RUN dotnet restore "TS.WebUI/TS.WebUI.csproj"
COPY . .
WORKDIR "/src/TS.WebUI"
RUN dotnet build "TS.UI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TS.UI.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TS.UI.dll"]
Here, I tried by adding ENV ASPNETCORE_HTTPS_PORT=4100
but it is also not working.
I also tried with Expose 4100
but that is also creating on localhost:{someRandomPort}:{ExposePort}
I have done it using compose. And it is working fine. For knowledge perspective I'm just trying if it is possible or not.
launchSettings.json
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_URLS": "https://+:443;http://+:80"
},
"publishAllPorts": false,
"useSSL": true,
"sslPort": 4100
}
We can provide specific port using sslPort.