由于缺lessdll:s,因此使用.NET Core 2.0构buildDocker多阶段失败
我有一个.NET核心networking应用程序,由dotnet new web -o foo
生成,以及以下(多阶段) Dockerfile
:
FROM microsoft/dotnet:2.0-sdk AS builder WORKDIR /build COPY ./foo/foo.csproj . RUN dotnet restore COPY ./foo/*.cs ./ RUN dotnet publish --configuration Release --output ./app FROM microsoft/dotnet:2.0-runtime WORKDIR /app COPY --from=builder /build/app/* ./ ENTRYPOINT ["dotnet", "./foo.dll"]
build立图像工作正常,但运行它不:
PS> docker build . -t foo # ... Successfully built <hash> Successfully tagged foo:latest PS> docker run --rm foo Error: An assembly specified in the application dependencies manifest (foo.deps.json) was not found: package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1' path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll' This assembly was expected to be in the local runtime store as the application was published using the following target manifest files: aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml
似乎不是所有必需的资产都发布到输出目录; 为了做这个工作我还需要做些什么?
有一个Github的问题 , 另一个解决同一个问题的方法是:
ASP.NET Core运行时存储不包含在“仅运行时”映像中。 您需要使用microsoft / aspnetcore:2.0.0,或select退出运行时存储区修剪。
如果你想要一个较小的图像,并可以更改代码,你可以这样做:
或(2)禁用发布时间修剪,以便将您的依赖关系程序集复制到发布的输出中。
<PropertyGroup> <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> </PropertyGroup>
- 在.NET Core上使用MongoDB Docker
- 什么会阻止在Docker容器中运行的代码连接到单独的服务器上的数据库?
- 是否有可能从Docker容器中运行我的开发asp.net核心服务器
- VSCode在连接到Windows泊坞窗容器上的远程debugging器时挂起在断点上
- Dotnet Core从Mac发布到IIS
- 在Docker中运行.Net Core 2.0上的IdentityServer4 – 访问主机资源
- 如何使用docker在dotnet上正常closures?
- 在Windows的Windows子系统中运行Docker中的.Net Core
- 在Linux上的Azure Web应用程序中运行dotnet核心docker映像时没有find可执行的匹配命令“dotnet – / .. /。dll”