Reputation: 69
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.
Upvotes: 2
Views: 11088
Reputation: 95
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.
Upvotes: 3
Reputation: 1
Seems that jar is not created :Try to Right Click > Run as > Maven install and then try "docker build" command. It worked for me!
Upvotes: -1