Docker build multistage - failed to compute cache key

triple check the name of the file that you are copying. The error is not intuitive but it means that it cannot find the file. In my case i was trying to copy a file but had a typo in the name of the file

Build Name Correct Name
build/libs/Attendance-app.war build/libs/Attendance.war

I had the wrong name all along.

I’m seeing this same behaviour today. Fresh install of docker from the official package repository in two different debian machines within the last day. Paths are definitely not the problem, one build is fine, the other errors out like this with a checksum error. The difference is that the broken environment is in a virtual machine (VirtualBox under Windows), the other is not

You can give it a try by pinning the WORKDIR and avoiding copying.

In the build stage, set a clear working directory and extract there:

FROM ... AS build
WORKDIR /workspace
ARG JAR_FILE=/target/*.jar
COPY ${JAR_FILE} /workspace/application.jar
RUN java -Djarmode=layertools -jar /workspace/application.jar extract

Then copy from /workspace/... paths. This prevents BuildKit from “walking” the whole root filesystem where /usr/lib/.build-id symlinks live.