gpt4 book ai didi

asp.net - Docker 从一个容器复制到另一个容器

转载 作者:搜寻专家 更新时间:2023-10-31 23:40:16 25 4
gpt4 key购买 nike

我有这个 docker 文件:

FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS build
WORKDIR /src
COPY *.sln ./
COPY MyApp.Api/MyApp.Api.csproj MyApp.Api/
RUN dotnet restore
COPY . .
WORKDIR /src/MyApp.Api
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
copy --from=build["C:\Program Files\nodejs", "C:\nodejs"]
RUN SETX PATH "%PATH%;C:\nodejs"
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]

我想将 nodejs 从 c:\Program Files\nodejs on build 复制到 C:\nodejs on final。但是当我构建它时,我得到了这个错误:

Step 15/19 : copy --from=publish ["C:\Program Files\nodejs", "C:\nodejs"]

ERROR: Service 'myapp.api' failed to build: failed to process "[\"C:\Program": unexpected end of statement while looking for matching double-quote

如何将 nodejs 从构建镜像复制到我的最终镜像?谢谢

最佳答案

如果 copy --from=publish ["C:\\Program Files\\nodejs", "C:\\nodejs"] 给出:

ERROR: Service 'myapp.api' failed to build: COPY failed: 
CreateFile \\?\Volume{acdcd1b2-fe0d-11e7-8a8f-10f00533bf2a}\C:Program Filesnodejs:

尝试双转义:

copy --from=publish ["C:\\\\Program Files\\\\nodejs", "C:\\\\nodejs"]

或考虑为in this Dockerfile替代语法:

copy --from=publish C:\Program Files\nodejs C:\nodejs

但是,aforementioned dockerfile确实使用这两种语法没有任何问题。例如:

COPY --from=SetupPhase ["C:\\Program Files (x86)\\Microsoft SDKs", "C:\\Program Files (x86)\\Microsoft SDKs"]

但是:它确实如此,在 copy --from 之前:

RUN icacls 'C:\\Program Files (x86)\\WindowsPowerShell\\Modules' /reset /t /c /q 
RUN attrib -h -r -s 'C:\\Program Files (x86)\\WindowsPowerShell\\Modules' /s
RUN attrib -h -r -s "C:/Windows" /s

(将这些路径替换为您要访问的路径)

这或许可以解释为什么它可以从另一个 Windows 镜像复制:没有访问问题,因为 ACL 已重置。

OP Luka确认:

  1. Add these lines to build

    RUN icacls "C:\\Program Files\\nodejs" /reset /t /c /q 
    RUN attrib -h -r -s "C:\\Program Files\\nodejs" /d /s
  2. Edited the copy line in final to this:

    COPY --from=build ["C:\\\\Program Files\\\\nodejs", "/nodejs"]

关于asp.net - Docker 从一个容器复制到另一个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48284298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com