docker - Docker 构建无法计算缓存键
问题描述
我有以下项目结构
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/22/2021 1:49 PM App_Start
d----- 3/20/2020 3:35 PM Areas
d----- 5/4/2021 7:01 PM bin
d----- 3/20/2020 3:35 PM Content
d----- 5/4/2021 5:59 PM Controllers
d----- 3/20/2020 3:35 PM fonts
d----- 8/20/2020 9:43 PM obj
d----- 7/9/2020 8:43 PM Properties
d----- 3/20/2020 3:35 PM Scripts
d----- 3/20/2020 3:35 PM Views
-a---- 5/4/2021 6:00 PM 46 .dockerignore
-a---- 5/4/2021 6:00 PM 45239 foo.csproj
-a---- 5/4/2021 11:21 PM 1621 foo.csproj.user
-a---- 4/22/2021 1:49 PM 390 ConnectionStrings.config
-a---- 5/5/2021 12:17 AM 375 Dockerfile
-a---- 3/20/2020 3:35 PM 116 Global.asax
-a---- 3/20/2020 3:35 PM 717 Global.asax.cs
-a---- 8/13/2020 1:05 PM 1770 NLog.config
-a---- 3/20/2020 3:35 PM 159853 NLog.xsd
-a---- 5/4/2021 6:00 PM 9217 packages.config
-a---- 3/20/2020 3:35 PM 12294 UnityConfiguration30.xsd
-a---- 5/4/2021 6:00 PM 29650 Web.config
-a---- 3/20/2020 3:35 PM 1308 Web.Debug.config
-a---- 3/20/2020 3:35 PM 705 Web.Release.config
我有一个bin directory
同名的目录是app.publish
.
我的 Dockerfile 如下所示:
#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/framework/aspnet:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY bin/app.publish .
在我运行下面的命令从这个 docker 文件构建图像之后
docker build -t soroshsabz/testcoreservice .
我收到以下错误
[+] Building 15.1s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 414B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 14.9s
=> [1/3] FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019@sha256:e1475e80eb3cbdfd81 0.1s
=> => resolve mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019@sha256:e1475e80eb3cbdfd81 0.1s
=> [internal] load build context 0.1s
=> => transferring context: 2B 0.0s
=> CACHED [2/3] WORKDIR /inetpub/wwwroot 0.0s
=> ERROR [3/3] COPY bin/app.publish . 0.0s
------
> [3/3] COPY bin/app.publish .:
------
failed to compute cache key: "/bin/app.publish" not found: not found
我的问题是为什么我得到这个错误?以及如何解决?
我Docker Engine Community 20.10.6
使用Windows 10 20H2 19042.964
我看到Docker - failed to compute cache key: not found - 在 Visual Studio和一些内部链接中运行良好,但没有找到任何有用的东西。
我正在解决我的问题并发现一些相同的问题,例如Dockerfile can't copy specified local directory & file或Windows Docker Dockerfile COPY file inside folder。
解决方案
感谢 BMitch,我发现了我的问题。问题是 dockerignore 文件包含一些不能与COPY
文件名匹配的模式。
我的问题是 dockerignore 文件中的模式与bin/app.publish
. 为了解决我的问题,我只需更改 dockerignore 中的模式。
推荐阅读
- redis - Django Compressor 应用时返回错误
- kaggle - 如何在 kaggle 上查看 .mdb 数据集?
- java - @Around 在 Spring Boot AOP 中的 @After、@Before、@AfterReturning 组合
- spyder - Spyder 变量资源管理器中的搜索工具丢失
- asp.net - 无法加载文件或程序集'log4net,版本 = 1.2.10.0,文化 = 中性水晶报告
- python - 对象没有属性“索引”
- azure-cosmosdb - 使用 SQL 语句查询时的 COSMOS DB 问题
- git - 如何使用 libgit2 在内存上构建/表示 git bare repo 的工作树
- javascript - 选择后 MUI 自动完成删除选项
- flutter - 如何在flutter中从pragma后台服务获取数据