[英]Docker copy from one container to another
I have this docker file: 我有这个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"]
And I want to copy nodejs from c:\\Program Files\\nodejs on build to C:\\nodejs on final . 我想在构建时将nodejs从c:\\ Program Files \\ nodejs 复制到最终的C:\\ nodejs 。 But when I build it i get this error:
但是当我构建它时,我得到了这个错误:
Step 15/19 : copy --from=publish ["C:\\Program Files\\nodejs", "C:\\nodejs"]
步骤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
错误:服务'myapp.api'无法构建:无法处理“[\\”C:\\ Program“:在查找匹配的双引号时意外结束语句
How can I copy nodejs from the build image to my final image? 如何将nodejs从构建映像复制到我的最终映像? Thanks
谢谢
If copy --from=publish ["C:\\\\Program Files\\\\nodejs", "C:\\\\nodejs"]
gives: 如果
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:
Try double-escape: 尝试双重逃脱:
copy --from=publish ["C:\\\\Program Files\\\\nodejs", "C:\\\\nodejs"]
Or consider as in this Dockerfile the alternative syntax: 或者在此Dockerfile中考虑替代语法:
copy --from=publish C:\Program Files\nodejs C:\nodejs
However, that aforementioned dockerfile does use both syntax without any issue. 但是, 前面提到的dockerfile确实使用了这两种语法而没有任何问题。 For example:
例如:
COPY --from=SetupPhase ["C:\\Program Files (x86)\\Microsoft SDKs", "C:\\Program Files (x86)\\Microsoft SDKs"]
But: it does, before the copy --from
: 但是:它确实在
copy --from
之前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
(Replace those paths by the one you want to access) (将那些路径替换为您要访问的路径)
That might explain why it can copy from another Windows image: no access problem because the ACLs were reset. 这可以解释为什么它可以从另一个Windows映像复制:没有访问问题,因为ACL被重置。
The OP Luka confirms: OP Luka确认:
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
Edited the copy line in final to this:
编辑了最后的副本行:
COPY --from=build ["C:\\\\\\\\Program Files\\\\\\\\nodejs", "/nodejs"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.