docker build stops at COPY with 'failed to compute cache key'
failed to compute cache key: "/app.csproj" not found: not foundShort answer
COPY and ADD only see files inside the build context, the directory you pass to docker build. The error means the source path is not in that context, or .dockerignore removed it. Run the build from the right folder, pass the right context with -f, or un-ignore the file.
Fix it fast
1Find out which cause you have
List what the build context contains from the directory you build in.
ls -la && docker build -f Dockerfile .2Match what you see, then jump to its fix
What does the error look like?
failed to compute cache key: "/app.csproj" not found: not foundfailed to solve: failed to compute cache key
Cause 1 of 2
The source path is outside or wrongly relative to the context
1Check
Paths resolve against the context root, and the Dockerfile location is set separately with -f. Files outside the context are unavailable.
docker build -f src/Api/Dockerfile .2Fix
Use the solution root as the context and the Dockerfile via -f; write COPY paths relative to the context.
docker build -f src/Api/Dockerfile -t api .
# in the Dockerfile
COPY src/Api/Api.csproj src/Api/3Verify
The COPY step now passes.
docker build -f src/Api/Dockerfile -t api .Confirmed by docs.docker.com
Cause 2 of 2
.dockerignore excludes the file
1Check
Files that match .dockerignore are removed from the context before it is sent, so COPY cannot see them.
cat .dockerignore2Fix
Add a negation after the pattern that hides the file (the last matching line wins).
*
!src/
!*.sln3Verify
Build again.
docker build -t app .Confirmed by docs.docker.com
How do I stop it coming back?
- Write the exact docker build command in the README or Makefile, with the context.
- Keep one .dockerignore per context and review it when files are added.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix