【异常解决】(一)解决docker报错failed to compute cache key: “...“ not found

7 篇文章 1 订阅
4 篇文章 0 订阅

本文章仅做记录异常用途

使用.net core右键LY.ProductSchedularService.Api自动生成dockerfile
并使用

docker build -t my_service .

构建镜像时,报错提示:
failed to compute cache key: “/App/LY/NetCore/LY.Common/LY.Common.csproj” not found: not found

DockerFile如下

#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项目同级的,因为该项目依赖引用了其他的2个项目,使用这个docker build命令会提示找不到另外的项目
解决方法:
把Dockerfile放于与App文件夹同级的目录下即可

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值