Docker - failed to compute cache key: not found - runs fine in Visual Studio Docker - failed to compute cache key: not found - runs fine in Visual Studio windows windows

Docker - failed to compute cache key: not found - runs fine in Visual Studio


Check your .dockerignore file. Possible it ignores needed files for copy command and you get failed to compute cache key error.


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

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.

Setup for my demo project is

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

So I would expect to go

cd \Workerservice2\WorkerService2docker 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

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 \Workerservice2docker build -f WorkerService2\Dockerfile --force-rm -t worker2/try7 .docker run -it worker2/try7    

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.


Asking for a directory that does not exist throws this error.

In my case, I tried

 > [stage-1  7/14] COPY /.ssh/id_rsa.pub /.ssh/:------failed to compute cache key: "/.ssh/id_rsa.pub" not found: not found

I had forgotten to add the /.ssh folder to the project directory. In your case you should check whether /client is really a subfolder of your Dockerfile build context.