I'm trying to run a .Net 8 application with this Dockerfile:
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:9000
EXPOSE 9000
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["EPS.Gateway/EPS.Gateway.csproj", "EPS.Gateway/"]
RUN dotnet restore "./EPS.Gateway/EPS.Gateway.csproj"
COPY . .
WORKDIR "/src/EPS.Gateway"
RUN dotnet build "./EPS.Gateway.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./EPS.Gateway.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "EPS.Gateway.dll", "--server.urls", "http://+:9000"]
I'm running it from Visual Studio 2022, but it doesn't run on http://localhost:9000/swagger/index.html as expected and get redirected to https://localhost:0/swagger
Its log says it's listening on port 9000:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:9000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:9000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
I tried every ways I saw on Stackoverflow but it didn't work.
I only had this problem. In my case i had wrong ports in my enviroments variebles. Make sure you have correct ports in DockerFile, docker-compose.yml and in enviroments variebles