Search code examples
asp.net-core-webapiamazon-ecsaws-fargateasp.net-core-7.0

ASP.NET Core 7.0 container: Failed to create CoreCLR, HRESULT: 0x8007000E


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>

Solution

  • 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