我目前正在為 .net Core 3.1 的 Docker 構建而苦苦掙扎,其中RUN快取了步驟,它們不應該這樣做,因為這應該始終執行:
#10 [build 4/4] RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config
#10 sha256:e8aeefc43305f5ab93d8c8fb78658174bdaa14d42c560daf9d764848da7f251c
#10 CACHED
這很可能是以下步驟失敗的原因:錯誤:“/app/publish”未找到:未找到:
#14 [final 2/2] COPY --from=base /app/publish .
#14 sha256:4a30ee4113a62bfd40731cdb0cd3a498eaee357df5736019ebd0629bd07f178e
#14 ERROR: "/app/publish" not found: not found
我將 Windows 上的 Docker Desktop 更新到版本 20.10.11,構建 dea9396,結果的輸出看起來略有不同,但結果相同:
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [build 2/4] WORKDIR /src 0.0s
=> CACHED [build 3/4] COPY . . 0.0s
=> CACHED [build 4/4] RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 - 0.0s
docker 檔案非常簡單:
FROM registry.intranet.company/ubi8/dotnet-31-runtime AS base
WORKDIR /app
EXPOSE 80
FROM registry.intranet.company/ubi8/dotnet-31 AS build
WORKDIR /src
USER root
COPY . .
RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config
USER default
FROM build AS final
WORKDIR /app
COPY --from=base /app/publish .
ENTRYPOINT ["dotnet", "FrontendWebApplication.UserManagement.dll"]
我已經嘗試了以下方法來解決這個問題:
- 在 docker 中修剪所有內容
- 停止和啟動 Docker 桌面
- 打電話
docker build --no-cache RUN在 Dockerfile 內的陳述句中添加 --no-cache 選項,如下所示:RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config --no-cache
我不是 100% 確定快取是否對找不到的檔案夾負責,所以原因可能完全不同,但由于我找不到禁用快取的方法,我根本不知道,這是我最好的猜測。
uj5u.com熱心網友回復:
最后一個復制命令應該來自構建,而不是來自基礎,您要發布到構建支付者,然后從基礎層創建最終。快取不是問題。
COPY --from=build /app/publish .
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/411640.html
標籤:
