[SOLVED] Unable to visualize Swagger UI in deployed container

Issue

I containerized a .NET webapi service including swagger and swagger UI. dotnet run runs the app correctly but when I containerized it I became unable to visualize the UI

Here is my dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src
COPY ["DataHandlerAPI.csproj", "./"]
RUN dotnet restore "./DataHandlerAPI.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "DataHandlerAPI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DataHandlerAPI.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DataHandlerAPI.dll"]

what should I change to make it run correctly as with dotnet run

Solution

I resolved this issue by adding these 2 lines line to my dockerfile

ENV ASPNETCORE_URLS http://*:80
ENV ASPNETCORE_ENVIRONMENT=Development

Answered By – Nesrinehk1

Answer Checked By – Clifford M. (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *