本文章僅做記錄異常用途
使用.net core右鍵LY.ProductSchedularService.Api自動生成dockerfile
并使用
docker build -t my_service .
構(gòu)建鏡像時,報(bào)錯提示:
failed to compute cache key: “/App/LY/NetCore/LY.Common/LY.Common.csproj” not found: not found
DockerFile如下文章來源:http://www.zghlxwxcb.cn/news/detail-504572.html
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 5677
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["App/LY/NetCore/LY.ProductSchedularService.Api/LY.ProductSchedularService.Api.csproj", "App/LY/NetCore/LY.ProductSchedularService.Api/"]
COPY ["App/LY/NetCore/LY.Entity/LY.Entity.csproj", "App/LY/NetCore/LY.Entity/"]
COPY ["App/LY/NetCore/LY.Common/LY.Common.csproj", "App/LY/NetCore/LY.Common/"]
RUN dotnet restore "App/LY/NetCore/LY.ProductSchedularService.Api/LY.ProductSchedularService.Api.csproj"
COPY . .
WORKDIR "/src/App/LY/NetCore/LY.ProductSchedularService.Api"
RUN dotnet build "LY.ProductSchedularService.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "LY.ProductSchedularService.Api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LY.ProductSchedularService.Api.dll"]
原因分析:
Dockerfile不能跟LY.ProductSchedularService.Api項(xiàng)目同級的,因?yàn)樵擁?xiàng)目依賴引用了其他的2個項(xiàng)目,使用這個docker build命令會提示找不到另外的項(xiàng)目
解決方法:
把Dockerfile放于與App文件夾同級的目錄下即可文章來源地址http://www.zghlxwxcb.cn/news/detail-504572.html
到了這里,關(guān)于【異常解決】(一)解決docker報(bào)錯failed to compute cache key: “...“ not found的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!