微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Docker 构建无法计算缓存密钥

如何解决Docker 构建无法计算缓存密钥

ITNOA

嗨,

我有以下项目结构

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 - runs fine in visual studiosome internal links,但没有找到任何有用的东西。

我正在处理我的问题并发现了一些相同的问题,例如 Dockerfile can’t copy specified local directory & fileWindows Docker Dockerfile COPY file inside folder

谢谢

解决方法

感谢 BMitch,我发现了我的问题,问题是 dockerignore 文件包含一些必须与 COPY 文件名不匹配的模式。我的问题是 dockerignore 文件中的模式与 bin/app.publish 错误匹配。为了解决我的问题,我只是更改了 dockerignore 中的模式。

再次感谢 BMitch

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?