本文章仅做记录异常用途
使用.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如下文章来源:https://www.toymoban.com/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项目同级的,因为该项目依赖引用了其他的2个项目,使用这个docker build命令会提示找不到另外的项目
解决方法:
把Dockerfile放于与App文件夹同级的目录下即可文章来源地址https://www.toymoban.com/news/detail-504572.html
到了这里,关于【异常解决】(一)解决docker报错failed to compute cache key: “...“ not found的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!