Asked by:
httpsys on docker with windows container

Question
-
User-1517163521 posted
Hi. I developed the application on .net core 2.2 with
Http.Sys
and I am trying to run it on docker with windows containerHere is the dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1903 AS base
WORKDIR /app
EXPOSE 5003
EXPOSE 443FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1903 AS build
WORKDIR /src
RUN mkdir IConductAPI.Core
COPY ["IConductAPI.Core/IConductCore.API.csproj", "IConductAPI.Core/"]
COPY ["IConduct.Model/IConductCore.Model.csproj", "IConduct.Model/"]
COPY ["IConduct.DAL/IConductCore.DAL.csproj", "IConduct.DAL/"]
COPY ["IConduct.LicenseCore/IConductCore.LicenseCore.csproj", "IConduct.LicenseCore/"]
COPY ["IConduct.GeneralHelpers/IConductCore.GeneralHelpers.csproj", "IConduct.GeneralHelpers/"]
RUN dotnet restore "IConductAPI.Core/IConductCore.API.csproj"
COPY . .
WORKDIR "/src/IConductAPI.Core"
RUN dotnet build "IConductCore.API.csproj" -c Release -o /app/buildFROM build AS publish
RUN dotnet publish "IConductCore.API.csproj" -c Release -o /app/publishFROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
#ENTRYPOINT ["dotnet", "IConductCore.API.dll"]
CMD ["dotnet","IConductCore.API.dll","--console"]I run docker build -t iconductapi . to build the image
and run the image with
docker run -it -p 5003:5003 -e ASPNETCORE_URLS="http://+" -e ASPNETCORE_ENVIRONMENT=Development --name icapi iconductapi
The output is :
[16:13:57.865+03:00 (0001)] [INF] Dependency Injection services have been configured.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\ContainerUser\AppData\Local\ASP.NET\DataProtection-Keys' as key reposit
ory and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {b523599c-9920-448c-a0f5-049b3fc06f52} with creation date 2020-08-16 13:13:57Z, activation date 2020-
08-16 13:13:57Z, and expiration date 2020-11-14 13:13:57Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file 'C:\Users\ContainerUser\AppData\Local\ASP.NET\DataProtection-Keys\key-b523599c-9920-448c-a0f5
-049b3fc06f52.xml'.
[16:13:58.022+03:00 (0001)] [INF] Applying configuration...
[16:13:58.024+03:00 (0001)] [INF] Use Cloudflare forward header options.
[16:13:59.096+03:00 (0001)] [INF] Use Swagger.
[16:13:59.240+03:00 (0001)] [INF] Use CORS.
[16:13:59.241+03:00 (0001)] [INF] Configuration has been aplied.
warn: Microsoft.AspNetCore.Server.HttpSys.MessagePump[0]
Overriding address(es) 'http://+'. Binding to endpoints added to UrlPrefixes instead.
info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
Start
info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
Listening on prefix: http://localhost:5003/
netstat on the container shows that the port is listening on 5003
However any end point that I am trying to hit gives me 403 error. For example , I have swagger and access it with ...:5003/swagger.html but get Forbidden URL
The application is NOT NEW and was executed without any problems without DOCKER. There is no authentication defined in the API
Sunday, August 16, 2020 2:03 PM
All replies
-
User-474980206 posted
with your configuration the docker host machine (the only machine with access) should work. Se sure to use localhost in the url.
Sunday, August 16, 2020 10:31 PM -
User-782232518 posted
Sounds like you didn't enable SwaggerUI, https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio#add-and-configure-swagger-middleware
Monday, August 17, 2020 1:54 AM -
User-1517163521 posted
Sorry not being specific , but here it is
- I do access localhost
- Swaggergen is enabled
- The same application works fine without docker for almost a year
- I get forbidden not only on swagger but on any endpoint
- There is no authentication/authorization in the application
Monday, August 17, 2020 5:45 AM