简体   繁体   中英

Asp.NET Core WebAPI not running in docker container

When I try to run my ASP.Net Core web api in a docker container, the application exitst early. My Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY . ./
RUN dotnet restore

FROM build AS publish
RUN dotnet publish -c Release -o /out/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /out/publish .
ENTRYPOINT ["dotnet", "WebService.dll"]

But when i try to run this container the only log thats displayed is this

2022/08/11 09:11:20.802 | Warn |  | Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository| Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.

and the container exitst with exit code 139. What am I doing wrong?

Th data Protection stores keys in the HOME directory (/root/.aspnet/DataProtection-Keys) so when the container restart the keys will be lost, and it might crash the service.

Add a Volume to

root/.aspnet/DataProtection-Keys 

To check if the error is something else, please build in the debug mood

RUN dotnet publish --output /app/ --configuration Debug

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM