英文:
ASP.NET Core 7.0 container: Failed to create CoreCLR, HRESULT: 0x8007000E
问题
这是我在尝试在Amazon ECS容器(AWS Fargate服务)中运行ASP.NET Core 7.0运行时映像后收到的结果。
我的项目是基于ASP.NET Core 7.0 Web API的。
以下是一个用于在Jenkins上构建并发送到Amazon ECS的映像的Docker文件:
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj", "src/MetaGame/MyMetaGame.API/"]
RUN dotnet restore "src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj"
COPY . .
WORKDIR "/src/src/MetaGame/MyMetaGame.API"
RUN dotnet build "MyMetaGame.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyMetaGame.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyMetaGame.API.dll"]
在一些搜索之后,我发现通过环境参数增加GC堆限制是一个解决方法。我将其设置为512Mb:
DOTNET_GCHeapHardLimit=20000000
但这没有解决我的问题。不清楚问题出在哪里。
以下是csproj文件的配置:
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
英文:
That's a result when I receive after trying to run ASP.NET Core 7.0 runtime image in Amazon ECS container (AWS Fargate service).
My project in on ASP.NET Core 7.0 Web API.
Here is a docker file for image which built on Jenkins and sent to Amazon ECS
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj", "src/MetaGame/MyMetaGame.API/"]
RUN dotnet restore "src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj"
COPY . .
WORKDIR "/src/src/MetaGame/MyMetaGame.API"
RUN dotnet build "MyMetaGame.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyMetaGame.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyMetaGame.API.dll"]
After some googling I've found a decision to increase GC Heap limit by environment parameter. I set it to 512Mb
DOTNET_GCHeapHardLimit=20000000
But it hasn't fixed my problem.
No idea what's the problem
Here is the configuration of csproj file
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
答案1
得分: 3
问题已通过在Dockerfile的最后阶段添加以下内容来解决:
ENV COMPlus_EnableDiagnostics=0
因此,应该如下所示:
FROM base AS final
ENV COMPlus_EnableDiagnostics=0
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyMetaGame.API.dll"]
在这里找到了解决方案。
英文:
So, the problem is fixed by adding
ENV COMPlus_EnableDiagnostics=0
in the final stage of Dockerfile.
So, it should looks like
FROM base AS final
ENV COMPlus_EnableDiagnostics=0
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyMetaGame.API.dll"]
Found the solution here
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论