I am deploying an API in my local docker using Docker Desktop for Windows. My API is running well on Visual Studio. I also tried deploying it on IIS and is working. But when I deployed it on Docker, I cannot view it on browser and cannot call the endpoints on Postman.
Here is my docker build and run commands:
docker build -f docker/local/Dockerfile -t kc.api.prototype
docker run -d --name kc.api.prototype --restart=unless-stopped -p 10230:80 kc.api.prototype
This runs without error. The container is also running. The only problem is that it cannot be seen on browser (I am using Swagger) and endpoints cannot be used.
Here is my DockerFile:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-local
WORKDIR /app
COPY ./kc-api-prototype ./
RUN dotnet restore *.csproj -s https://api.nuget.org/v3/index.json
RUN dotnet publish *.csproj -c Dev -o out
# build runtime image
# FROM microsoft/dotnet:aspnetcore-runtime REMOVED: Upgraded to .NET Core 3.1
FROM mcr.microsoft.com/dotnet/sdk:6.0
RUN apt-get update \
&& apt-get install -y --allow-unauthenticated \
libc6-dev \
libgdiplus \
libx11-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build-local /app/out ./
ENTRYPOINT ["dotnet", "kc-api-prototype.dll"]
I already tried removing app.UseHttpsRedirection() as suggested on other posts. I haven't tried disabling SSL since I cannot access the property on Visual Studio 2022.
launchSettings.json