docker - 无法计算缓存键:未找到 - 在 Visual Studio 中运行良好 [英] docker - failed to compute cache key: not found - runs fine in visual studio

查看:48
本文介绍了docker - 无法计算缓存键:未找到 - 在 Visual Studio 中运行良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用 VS 生成了一个 Dockerfile,它在 VS 中运行得很好,现在我正在尝试从 Windows 本身构建它(docker buid . ,我尝试了很多组合).但是我收到以下错误

So I've generated a Dockerfile with VS, it runs in VS just fine and now I'm trying to build it from windows itself(docker buid . , I tried many combinations). Yet I get the following error

当我将 copy 更改为 ./client.csproj 时,它确实会继续,然后我得到

When I change copy to ./client.csproj it does continue and then I get

我做错了什么?我把Docker linux改成了windows,改了WSL,重启了一切

What am I doing wrong? I changed Docker linux to windows, changed WSL, restarted everything

提前致谢

Dockerfile 客户端

推荐答案

Visual Studio 的处理方式有点奇怪.

The way Visual Studio does it is a little bit odd.

它不是在带有 Dockerfile 的文件夹中启动 docker build,而是在父文件夹中启动并使用 -f 选项指定 Dockerfile.

Instead of launching docker build in the folder with the Dockerfile, it launches in the parent folder and specifies the Dockerfile with the -f option.

我正在使用演示项目(试图为另一个问题创建一个最小的解决方案)并遇到了同样的情况.

I was using the demo project (trying to create a minimal solution for another question) and struck the same situation.

我的演示项目的设置是

\WorkerService2  ("solution" folder)
   +- WorkerService2.sln
   +- WorkserService2  ("project" folder)
       +- DockerFile
       +- WorkerService2.csproj
       +- ... other program files

所以我期待

cd \Workerservice2\WorkerService2
docker build .

但是我收到了你的错误信息.

But I get your error message.

 => ERROR [build 3/7] COPY [WorkerService2/WorkerService2.csproj, WorkerService2/]                                                                                                                        0.0s
------
 > [build 3/7] COPY [WorkerService2/WorkerService2.csproj, WorkerService2/]:
------
failed to compute cache key: "/WorkerService2/WorkerService2.csproj" not found: not found

相反,使用 .sln 文件转到父目录并使用 docker -f 选项指定要在子文件夹中使用的 Dockerfile:

Instead, go to the parent directory, with the .sln file and use the docker -f option to specify the Dockerfile to use in the subfolder:

cd \Workerservice2
docker build -f WorkerService2\Dockerfile --force-rm -t worker2/try7 .

docker run -it worker2/try7    

注意docker命令的最后一部分,通常是Dockerfile所在的文件夹,是local directlry,指定Dockerfile.

Note that the final part of the docker command, which is usually the folder with the Dockerfile in, is local directlry, and the Dockerfile is specified.

我通过检查构建过程的输出进入了这个阶段,详细程度设置为详细.如果您选择工具/选项/项目和解决方案/构建和运行,您可以调整构建输出的详细程度,我做了详细说明.

I got to this stage by inspecting the output of the build process, with verbosity set to Detailed. If you choose Tools / Options / Projects and Solutions / Build and Run you can adjust the build output verbosity, I made mine Detailed.

这篇关于docker - 无法计算缓存键:未找到 - 在 Visual Studio 中运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆