[英]How to copy a directory from docker container to host using Dockerfile?
[英]Docker copy from one container to another
我有這個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 復制到最終的C:\\ nodejs 。 但是當我構建它時,我得到了這個錯誤:
步驟15/19:copy --from = publish [“C:\\ Program Files \\ nodejs”,“C:\\ nodejs”]
錯誤:服務'myapp.api'無法構建:無法處理“[\\”C:\\ Program“:在查找匹配的雙引號時意外結束語句
如何將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"]
或者在此Dockerfile中考慮替代語法:
copy --from=publish C:\Program Files\nodejs C:\nodejs
但是, 前面提到的dockerfile確實使用了這兩種語法而沒有任何問題。 例如:
COPY --from=SetupPhase ["C:\\Program Files (x86)\\Microsoft SDKs", "C:\\Program Files (x86)\\Microsoft SDKs"]
但是:它確實在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
(將那些路徑替換為您要訪問的路徑)
這可以解釋為什么它可以從另一個Windows映像復制:沒有訪問問題,因為ACL被重置。
OP Luka確認:
添加這些行來構建
RUN icacls "C:\\\\Program Files\\\\nodejs" /reset /t /c /q RUN attrib -h -r -s "C:\\\\Program Files\\\\nodejs" /d /s
編輯了最后的副本行:
COPY --from=build ["C:\\\\\\\\Program Files\\\\\\\\nodejs", "/nodejs"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.