docker - 构建 docker 图像 asp.net 核心时出现 OutofMemory 异常
问题描述
在构建基于 asp.net 核心的 docker 映像时,我会定期遇到以下异常
/usr/share/dotnet/sdk/2.2.300/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]
/usr/share/dotnet/sdk/2.2.300/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Unhandled Exception: OutOfMemoryException. [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]
码头工人文件
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 12201
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["OrchestratorReverseProxy/OrchestratorReverseProxy.csproj", "OrchestratorReverseProxy/"]
RUN dotnet restore "OrchestratorReverseProxy/OrchestratorReverseProxy.csproj" /p:EnableDefaultItems=false
COPY . .
WORKDIR "/src/OrchestratorReverseProxy"
RUN dotnet build "OrchestratorReverseProxy.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "OrchestratorReverseProxy.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "OrchestratorReverseProxy.dll"]
构建日志
Restore completed in 395.8 ms for /src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj.
/usr/share/dotnet/sdk/2.1.700/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]
/usr/share/dotnet/sdk/2.1.700/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.CodeAnalysis.CSharp.Symbols.ExtraAnnotations' threw an exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
解决方案
推荐阅读
- sql-server - 多个嵌套内连接:并非所有记录都显示
- react-native - 我可以使用 React Native 将样式应用于用户输入中的文本子集吗?
- jquery - Select2 在预设标签元素上启用编辑/键入
- python - 如何从 keras/tensorflow 中的顺序模型中获取 logits?
- anychart - 为父组分隔符设置全宽行颜色
- sql - SQL Server 检查约束可为空
- java - 在创建新对象时尝试为 JNI 对象的构造函数提供参数时出错
- performance - Haskell 程序运行很慢
- lua - 试图理解自定义迭代器
- postgresql - PostgreSQL 中的数组和 IN 运算符