Laden...

.NET Core 2.2 in Alpine Docker Image -> Alle Anfragen Status 200 mit content-length 0

Erstellt von Campy vor 5 Jahren Letzter Beitrag vor 5 Jahren 1.236 Views
C
Campy Themenstarter:in
439 Beiträge seit 2008
vor 5 Jahren
.NET Core 2.2 in Alpine Docker Image -> Alle Anfragen Status 200 mit content-length 0

Hallo zusammen,

ich habe eine .net Core 2.2 Console Anwendung in einem Alpine Docker Container laufen.
Bei mir lokal funktioniert die Anwendung einwandfrei, wird diese allerdings im Container ausgeführt, so werden alle Requests mit Status 200 und content-lenght 0 beantwortet.
Die Requests stehen sogar in den Container Logs (Kestrel).

Hat jemand schon einmal dieses Problem gehabt oder eine Lösung dafür?

Vielen Dank im Voraus!

EDIT: Hab es entsprechend dem DockerFile auch mal auf einem Ubuntu mit installiertem .net Core compiliert - selbes Ergebnis. Habe ich einen Fehler im Build-Prozess?:

#FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine as base
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine as base
WORKDIR /app
EXPOSE 11007

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine as builder

COPY . /app
WORKDIR /app/Common
RUN ["dotnet", "restore"]

WORKDIR /app/DataAccess
RUN ["dotnet", "restore"]

WORKDIR /app/ERPSystem
RUN ["dotnet", "restore"]

WORKDIR /app/GlobalLibrary
RUN ["dotnet", "restore"]

WORKDIR /app/Hoster
RUN ["dotnet", "restore"]

WORKDIR /app/Model
RUN ["dotnet", "restore"]

WORKDIR /app/Service
RUN ["dotnet", "restore"]

WORKDIR /app/Hoster
#RUN ["dotnet", "build"]
RUN dotnet build -c Debug -o /result

FROM builder AS publish
RUN dotnet publish -c Debug -o /result

FROM base AS final
COPY ["settings.json", "/usr/share"]
WORKDIR /app
COPY --from=publish /result .

ENTRYPOINT ["dotnet", "Hoster.dll"]

EDIT:

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]


      User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.


info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]


      Creating key {58e5ff23-4d49-4a39-8e67-118d1bcdb07c} with creation date 2019-03-15 10:27:43Z, activation date 2019-03-15 10:27:43Z, and expiration date 2019-06-13 10:27:43Z.


warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]


      No XML encryptor configured. Key {58e5ff23-4d49-4a39-8e67-118d1bcdb07c} may be persisted to storage in unencrypted form.


info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]


      Writing data to file '/root/.aspnet/DataProtection-Keys/key-58e5ff23-4d49-4a39-8e67-118d1bcdb07c.xml'.


warn: Microsoft.AspNetCore.Server.Kestrel[0]


      Overriding address(es) 'http://+:80'. Binding to endpoints defined in UseKestrel() instead.


Hosting environment: Production


Content root path: /app


Now listening on: http://0.0.0.0:11007


Application started. Press Ctrl+C to shut down.


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.0 GET http://sdk.service.consul:11007/api/clients  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 278.3978ms 200 


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.1 GET http://localhost:11007/api/clients  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 0.6902ms 200 


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.1 GET http://172.16.3.0:11007/api/clients  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 0.6707ms 200 


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.1 GET http://172.16.3.0:11007/favicon.ico  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 0.1266ms 200 


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.1 GET http://172.16.3.0:11007/api/clients  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 0.225ms 200 


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]


      Request starting HTTP/1.1 GET http://172.16.3.0:11007/favicon.ico  


info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]


      Request finished in 0.3618ms 200 

A programmer is just a tool, which converts coffeine into code! 🙂

C
Campy Themenstarter:in
439 Beiträge seit 2008
vor 5 Jahren

So ich habe nun (so wie es auf den ersten Blick aussieht) mein Problem lösen können:

Meine Controlelr befinden sich zusammen mit der Startup.cs in einer anderen Assembly.
Unter Windows funktionierte folgender Code:


services.AddMvc();

unter Linux muss man den Code folgendermaßen erweitern damit die Controller der anderen Assembly aufgerufen werden:


services.AddMvc().AddApplicationPart(typeof(ClientsController).Assembly);

A programmer is just a tool, which converts coffeine into code! 🙂