httpsys on docker with windows container RRS feed

  • Question

  • User-1517163521 posted

    Hi. I developed the application on .net core 2.2 with

    and I am trying to run it on docker with windows container

    Here is the dockerfile

    FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1903 AS base
    WORKDIR /app
    EXPOSE 5003
    EXPOSE 443

    FROM 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/build

    FROM build AS publish
    RUN dotnet publish "IConductCore.API.csproj" -c Release -o /app/publish

    FROM 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


    [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]


    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