New to docker, trying to build a Java Spring web app. Created a Dockerfile in my application folder 'Feedback Collection System':
> FROM openjdk:19
> VOLUME /tmp
> EXPOSE 8080
> ARG JAR_FILE=target/*.jar
> ADD ${JAR_FILE} FeedbackColletionSystem.jar
> ENTRYPOINT ["java","-jar","/app.jar"]
Created an artifact, builded jar file in 'out' folder if its relevant. Runed a command C:\Users\myname\IdeaProjects\Feedback Collection System> docker build -t fcs . And recieved such an error -
=> ERROR [2/2] ADD target/fcs-docker.jar app.jar 0.0s
------
[2/2] ADD target/fcs-docker.jar app.jar:
------
Dockerfile:5
--------------------
3 | EXPOSE 8080
4 | ARG JAR_FILE=target/fcs-docker.jar
5 | >>> ADD ${JAR_FILE} app.jar
6 | ENTRYPOINT ["java","-jar","/app.jar"]
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref c6c2b90b-d036-468a-af5f-109679f007da::ffr4qbgvxpsv1750xol8t3sou:
failed to walk /var/lib/docker/tmp/buildkit-mount2615739737/target:
lstat /var/lib/docker/tmp/buildkit-mount2615739737/target: no such file or directory
Please help. Thanks.
I had a similar problem. It turned out that I accidentally had the target folder in .dockerignore. This meant that Docker couldn't get that folder into its build context and that's why it couldn't find it. It was probably a copy paste error from my .gitignore.
So obviously the solution was to remove the target folder from .dockerignore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With