[英]Docker build image fails - No such file or directory
I created a.Net Core app in Visual Sutdio 2019 and added docker support so it automatically generates the file but when I build the docker image the output says:我在 Visual Sutdio 2019 中创建了一个.Net Core 应用程序并添加了 docker 支持,因此它会自动生成文件,但是当我构建 docker 图像时,Z78E6221F6393D1356681DB398F14CE6D
1>/root/.nuget/packages/microsoft.typescript.msbuild/3.9.5/tools/Microsoft.TypeScript.targets(551,5):
error MSB6003: The specified task executable "node" could not be run. System.ComponentModel.Win32Exception
(2): No such file or directory [/src/CyberEvalNextGen.csproj]
I assume there is an issue with COPY but I am not sure.我认为 COPY 存在问题,但我不确定。
Here is my docker file:这是我的 docker 文件:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["CyberEvalNextGen.csproj", ""]
RUN dotnet restore "./CyberEvalNextGen.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "CyberEvalNextGen.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "CyberEvalNextGen.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CyberEvalNextGen.dll"]
I had the same issue.我遇到过同样的问题。 The error is a bit misleading because it has your.csproj listed at the end, but this is the key part:
该错误有点误导,因为它最后列出了 your.csproj,但这是关键部分:
The specified task executable "node" could not be run.
It is actually looking to run the command "node" and it cannot find the executable.它实际上正在寻找运行命令“节点”并且找不到可执行文件。 To resolve this, I added Node.js just prior to my build step.
为了解决这个问题,我在构建步骤之前添加了 Node.js。
...
WORKDIR "/src/."
#Installing Node.js in build container
RUN apt-get update && apt-get -y install nodejs
RUN dotnet build "CyberEvalNextGen.csproj" -c Release -o /app/build
...
This is using Linux containers, but I believe you can do something similar with PowerShell in Windows containers.这是使用 Linux 容器,但我相信您可以在 Windows 容器中使用 PowerShell 做类似的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.