This is my Dockerfile:
FROM openjdk:8
EXPOSE 8080
ADD target/springboot-example.jar springboot-example.jar
ENTRYPOINT ["java","-jar","/springboot-example.jar"]
While running docker build, I see this error:
Step 3/4 : ADD target/springboot-example.jar springboot-example.jar
ADD failed: file not found in build context or excluded by .dockerignore: stat target/springboot-example.jar: file does not exist
In my case, the target file isn't match with pom.xml file.
Your target
springboot-exampleis the (<artifactId>+<version>.jar) in pom.xml. I thinkspringboot-exampleyou declared in the dockerfile is doesn't match with artifactId and version tag in the pom.xml file. Just make sure your project with follow this step:Step-1
go to the pom.xml file and make sure your
<grupId>and<artifactId>its same with your Dockerfile targetStep-2
Setting the Dockerfile, for my project it will be like this:
Its SOLVED in my case, good luck dude!