Reputation: 4211
I have this docker file:
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. But when I build it i get this error:
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
How can I copy nodejs from the build image to my final image? Thanks
Upvotes: 4
Views: 6577
Reputation: 1324987
If copy --from=publish ["C:\\Program Files\\nodejs", "C:\\nodejs"]
gives:
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:
copy --from=publish C:\Program Files\nodejs C:\nodejs
However, that aforementioned dockerfile does use both syntax without any issue. For example:
COPY --from=SetupPhase ["C:\\Program Files (x86)\\Microsoft SDKs", "C:\\Program Files (x86)\\Microsoft SDKs"]
But: it does, before the 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.
The OP Luka confirms:
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"]
Upvotes: 5