我正在尝试将docker支持添加到现有的ASP.NET Core 2.1 Web应用程序中.在dotnet build命令期间失败,说它无法加载共享库kernel32.dll和libkernel32.dll.我有以下Dockerfile
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY . .
RUN ls -la
WORKDIR /src/WebRazorPages
RUN ls -la
RUN dotnet restore -nowarn:msb3202,nu1503
RUN dotnet build --no-restore -c Release -o /app
FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet","WebRazorPages.dll"]
它运行到dotnet构建步骤没有错误,但随后在找到共享文件作为目标文件构建过程的一部分时失败.完整输出如下所示:
1>------ Build started: Project: WebRazorPages,Configuration: Release Any cpu ------
1>You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
1>docker exec -i 44ded24c4cef1fbf9539449dac737aa39e7c255d6a4da9f09106fb689be2a769 /bin/bash -c "if PID=$(pidof -x dotnet); then kill $PID; fi"
1>WebRazorPages -> C:\dev\github\eShopOnWeb\src\WebRazorPages\bin\Release\netcoreapp2.1\Microsoft.eShopWeb.RazorPages.dll
1>WebRazorPages -> C:\dev\github\eShopOnWeb\src\WebRazorPages\bin\Release\netcoreapp2.1\Microsoft.eShopWeb.RazorPages.Views.dll
1>docker build -f "C:\dev\github\eShopOnWeb\src\WebRazorPages\Dockerfile" -t microsoft.eshopweb.razorpages "C:\dev\github\eShopOnWeb\src"
1>Sending build context to Docker daemon 35.46MB
1>
1>Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
1> ---> 083ca6a642ea
1>Step 2/17 : WORKDIR /app
1> ---> Using cache
1> ---> b0c93ee1eca8
1>Step 3/17 : EXPOSE 80
1> ---> Using cache
1> ---> 76e2ed0decb7
1>Step 4/17 : FROM microsoft/dotnet:2.1-sdk AS build
1> ---> 1f63052e44c2
1>Step 5/17 : WORKDIR /src
1> ---> Using cache
1> ---> 1c80bb67fe43
1>Step 6/17 : COPY . .
1> ---> d97c2bf3a900
1>Step 7/17 : RUN ls -la
1> ---> Running in ecb2727f2649
1>total 24
1>drwxr-xr-x 1 root root 4096 May 21 14:37 .
1>drwxr-xr-x 1 root root 4096 May 21 14:37 ..
1>drwxr-xr-x 9 root root 4096 May 19 19:11 ApplicationCore
1>drwxr-xr-x 8 root root 4096 May 19 20:48 Infrastructure
1>drwxr-xr-x 13 root root 4096 May 19 22:18 Web
1>drwxr-xr-x 13 root root 4096 May 21 14:37 WebRazorPages
1>Removing intermediate container ecb2727f2649
1> ---> 01618f215b1a
1>Step 8/17 : WORKDIR /src/WebRazorPages
1>Removing intermediate container 7d812e8c1852
1> ---> b0c821c0cd10
1>Step 9/17 : RUN ls -la
1> ---> Running in 7055f247949a
1>total 100
1>drwxr-xr-x 13 root root 4096 May 21 14:37 .
1>drwxr-xr-x 1 root root 4096 May 21 14:37 ..
1>-rwxr-xr-x 1 root root 36 Oct 24 2017 .bowerrc
1>-rwxr-xr-x 1 root root 261 Apr 3 14:35 Constants.cs
1>drwxr-xr-x 2 root root 4096 Oct 24 2017 Controllers
1>-rwxr-xr-x 1 root root 475 May 21 14:37 Dockerfile
1>drwxr-xr-x 2 root root 4096 Oct 24 2017 Extensions
1>drwxr-xr-x 2 root root 4096 Oct 24 2017 Interfaces
1>drwxr-xr-x 6 root root 4096 May 19 21:36 Pages
1>-rwxr-xr-x 1 root root 1644 May 21 14:35 Program.cs
1>drwxr-xr-x 2 root root 4096 May 19 22:18 Properties
1>drwxr-xr-x 2 root root 4096 Oct 24 2017 Services
1>-rwxr-xr-x 1 root root 6297 May 19 21:11 Startup.cs
1>drwxr-xr-x 2 root root 4096 Apr 3 14:35 ViewComponents
1>drwxr-xr-x 2 root root 4096 Oct 24 2017 viewmodels
1>-rwxr-xr-x 1 root root 915 May 21 13:45 WebRazorPages.csproj
1>-rwxr-xr-x 1 root root 388 May 21 13:45 WebRazorPages.csproj.user
1>-rwxr-xr-x 1 root root 178 Oct 24 2017 appsettings.Development.json
1>-rwxr-xr-x 1 root root 113 Oct 24 2017 appsettings.json
1>drwxr-xr-x 4 root root 4096 May 21 13:59 bin
1>-rwxr-xr-x 1 root root 207 Oct 24 2017 bower.json
1>-rwxr-xr-x 1 root root 628 Oct 24 2017 bundleconfig.json
1>drwxr-xr-x 5 root root 4096 May 21 13:59 obj
1>drwxr-xr-x 7 root root 4096 Oct 24 2017 wwwroot
1>Removing intermediate container 7055f247949a
1> ---> 74b0f03086c2
1>Step 10/17 : RUN dotnet restore -nowarn:msb3202,nu1503
1> ---> Running in 33852929709e
1> Restoring packages for /src/Infrastructure/Infrastructure.csproj...
1> Restoring packages for /src/ApplicationCore/ApplicationCore.csproj...
1> Installing Ardalis.GuardClauses 1.2.3.
1> Generating MSBuild file /src/ApplicationCore/obj/ApplicationCore.csproj.nuget.g.props.
1> Generating MSBuild file /src/ApplicationCore/obj/ApplicationCore.csproj.nuget.g.targets.
1> Restore completed in 1.01 sec for /src/ApplicationCore/ApplicationCore.csproj.
1> Restoring packages for /src/WebRazorPages/WebRazorPages.csproj...
1> Installing System.Security.Cryptography.Cng 4.4.0.
1> Installing System.Numerics.Vectors 4.4.0.
1> Installing System.Buffers 4.4.0.
1> Generating MSBuild file /src/Infrastructure/obj/Infrastructure.csproj.nuget.g.props.
1> Generating MSBuild file /src/Infrastructure/obj/Infrastructure.csproj.nuget.g.targets.
1> Restore completed in 2.85 sec for /src/Infrastructure/Infrastructure.csproj.
1> Installing System.Runtime.CompilerServices.Unsafe 4.5.0-preview1-26216-02.
1> Installing Microsoft.Extensions.Logging.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.DependencyInjection.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.Configuration.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.Primitives 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.Hosting.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.AspNetCore.Hosting.Server.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.FileSystemGlobbing 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.FileProviders.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Net.Http.Headers 2.1.0-preview1-final.
1> Installing System.Buffers 4.5.0-preview1-26216-02.
1> Installing Microsoft.AspNetCore.Http.Features 2.1.0-preview1-final.
1> Installing System.Text.Encodings.Web 4.5.0-preview1-26216-02.
1> Installing Microsoft.AspNetCore.Hosting.Abstractions 2.1.0-preview1-final.
1> Installing Microsoft.Extensions.FileProviders.Physical 2.1.0-preview1-final.
1> Installing Microsoft.AspNetCore.Http.Extensions 2.1.0-preview1-final.
1> Installing Microsoft.VisualStudio.Azure.Containers.Tools.Targets 0.1.1646902.
1> Installing Microsoft.VisualStudio.Web.BrowserLink 2.1.0-preview1-final.
1> Installing Microsoft.AspNetCore.Http.Abstractions 2.1.0-preview1-final.
1> Generating MSBuild file /src/WebRazorPages/obj/WebRazorPages.csproj.nuget.g.props.
1> Generating MSBuild file /src/WebRazorPages/obj/WebRazorPages.csproj.nuget.g.targets.
1> Restore completed in 2.49 sec for /src/WebRazorPages/WebRazorPages.csproj.
1>Removing intermediate container 33852929709e
1> ---> 0e020cc66427
1>Step 11/17 : RUN dotnet build --no-restore -c Release -o /app
1> ---> Running in da8aed1609f1
1>Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: The "KillAppInsideContainer" task Failed unexpectedly. [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: System.DllNotFoundException: Unable to load shared library 'kernel32.dll' or one of its dependencies. In order to help diagnose loading problems,consider setting the LD_DEBUG environment variable: libkernel32.dll: cannot open shared object file: No such file or directory [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Common.Prerequisites.DockerForWindowsRunningPrerequisite.WaitNamedPipe(String name,Int32 timeout) [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Common.Prerequisites.DockerForWindowsRunningPrerequisite.EvaluateAsync(CancellationToken cancellationToken) [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Common.Prerequisites.CompositePrerequisite.EvaluateAsync(CancellationToken cancellationToken) [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.HandleExceptionAsync(Exception ex,ContainerBuildTaskContext context) [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.ExecuteAsync(ContainerBuildTaskContext context) [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.Execute() [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/src/WebRazorPages/WebRazorPages.csproj]
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost,TaskLoggingContext taskLoggingContext,TaskHost taskHost,ItemBucket bucket,TaskExecutionMode howToExecuteTask) [/src/WebRazorPages/WebRazorPages.csproj]
1>Build Failed.
1>
1>/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/0.1.1646902/build/Container.targets(188,TaskExecutionMode howToExecuteTask) [/src/WebRazorPages/WebRazorPages.csproj]
1> 0 Warning(s)
1> 1 Error(s)
1>
1>Time Elapsed 00:00:00.66
1>The command '/bin/sh -c dotnet build --no-restore -c Release -o /app' returned a non-zero code: 1
1>C:\Users\steve\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\0.1.1646902\build\Container.targets(212,5): error : An error occurred while attempting to build Docker image.
1>Done building project "WebRazorPages.csproj" -- Failed.
========== Build: 0 succeeded,1 Failed,2 up-to-date,0 skipped ==========
为什么当文件清楚地出现在文件夹中并且只是成功用于执行网络还原时,它无法找到该文件?
UPDATE
该错误建议设置LD_DEBUG,所以我做了,它产生了这个信息:
21: calling init: /lib/x86_64-linux-gnu/libnss_dns.so.2
21:
21: find library=kernel32.dll.so [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/kernel32.dll.so
21: trying file=/usr/lib/x86_64-linux-gnu/kernel32.dll.so
21: trying file=/lib/kernel32.dll.so
21: trying file=/usr/lib/kernel32.dll.so
21:
21: find library=libkernel32.dll.so [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/libkernel32.dll.so
21: trying file=/usr/lib/x86_64-linux-gnu/libkernel32.dll.so
21: trying file=/lib/libkernel32.dll.so
21: trying file=/usr/lib/libkernel32.dll.so
21:
21: find library=kernel32.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/kernel32.dll
21: trying file=/usr/lib/x86_64-linux-gnu/kernel32.dll
21: trying file=/lib/kernel32.dll
21: trying file=/usr/lib/kernel32.dll
21:
21: find library=libkernel32.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/libkernel32.dll
21: trying file=/usr/lib/x86_64-linux-gnu/libkernel32.dll
21: trying file=/lib/libkernel32.dll
21: trying file=/usr/lib/libkernel32.dll
21:
21: find library=Microsoft.DiaSymReader.Native.amd64.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/lib/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/Microsoft.DiaSymReader.Native.amd64.dll
21:
21: find library=Microsoft.DiaSymReader.Native.amd64.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/lib/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/Microsoft.DiaSymReader.Native.amd64.dll
21:
21: find library=Microsoft.DiaSymReader.Native.amd64.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/lib/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/Microsoft.DiaSymReader.Native.amd64.dll
21:
21: find library=Microsoft.DiaSymReader.Native.amd64.dll [0]; searching
21: search cache=/etc/ld.so.cache
21: search path=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib:/usr/lib (system search path)
21: trying file=/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/x86_64-linux-gnu/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/lib/Microsoft.DiaSymReader.Native.amd64.dll
21: trying file=/usr/lib/Microsoft.DiaSymReader.Native.amd64.dll
21:
最佳答案
原文链接:https://www.f2er.com/docker/435794.html