ASP.NET Core 7.0容器: 无法创建CoreCLR,HRESULT: 0x8007000E

huangapple go评论143阅读模式
英文:

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 [&quot;src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj&quot;, &quot;src/MetaGame/MyMetaGame.API/&quot;]
RUN dotnet restore &quot;src/MetaGame/MyMetaGame.API/MyMetaGame.API.csproj&quot;
COPY . .
WORKDIR &quot;/src/src/MetaGame/MyMetaGame.API&quot;
RUN dotnet build &quot;MyMetaGame.API.csproj&quot; -c Release -o /app/build

FROM build AS publish
RUN dotnet publish &quot;MyMetaGame.API.csproj&quot; -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [&quot;dotnet&quot;, &quot;MyMetaGame.API.dll&quot;] 

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

&lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;net7.0&lt;/TargetFramework&gt;
    &lt;Nullable&gt;enable&lt;/Nullable&gt;
    &lt;ImplicitUsings&gt;enable&lt;/ImplicitUsings&gt;
    &lt;DockerDefaultTargetOS&gt;Linux&lt;/DockerDefaultTargetOS&gt;
&lt;/PropertyGroup&gt;

答案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 [&quot;dotnet&quot;, &quot;MyMetaGame.API.dll&quot;]

Found the solution here

huangapple
  • 本文由 发表于 2023年6月1日 23:30:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76383522.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定