Docker build giving failed to compute cache key: not found

I created Dockerfile which contains following code -
FROM alpine/git as clone
RUN git clone
FROM maven:3.5-jdk-8-alpine as build
COPY --from=clone /app/FirstProject /app
RUN mvn install
CMD [“echo”,“Stage 2 complete”]
FROM openjdk:8-jre-alpine
COPY --from=build /app/target/firstproject-1.0-snapshot.jar /app
CMD [“java -jar firstproject-1.0-snapshot.jar”]
It is giving below error -
=> ERROR [stage-2 3/3] COPY --from=build /app/target/firstproject-1.0-snapshot.jar /app 0.> [stage-2 3/3] COPY --from=build /app/target/firstproject-1.0-snapshot.jar /app:
failed to compute cache key: “/app/target/firstproject-1.0-snapshot.jar” not found: not found

Could someone pls. point the issue.

Hi @johari.anant

I successfully built your dockerfile exactly as you have pasted it above (using Docker 20.10.10).

Have you put it in a directory by itself? If there are other files present, this may cause confusion.


  1. Put Dockerfile into a directory by itself
  2. cd into that directory
  3. Run docker build .

You can search google for failed to compute cache key - there are a number of articles.