0

I am new to docker. I have a maven wrapper which build package my application and copy the deployables into new folder and then run it. I am getting this error.

COPY failed: stat /var/lib/docker/tmp/docker-builder102689450/app/q-runner/target/q-runner-0.0.1-runner.jar: no such file or directory

Why should the file searched in above location when I mentioned to copy from /app/.

My docker file is

 # docker build -f Dockerfile.build -t abc/notify-build . FROM adoptopenjdk/openjdk14:ubi WORKDIR /app COPY ./ /app RUN chmod +x ./mvnw && \ ./mvnw package ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 COPY /app/target/*-runner.jar /deployments/app.jar CMD java -jar /deployments/app.jar 
2
  • The location shown in your error message is the docker build context, i.e. the one that is created from your docker build <context> command. You cannot copy anything that is outside of the context. Any source starting with / in your copy command is searched from the context root. You cannot either navigate out the context by using something like ../../../app/ which will fire an error. Commented Sep 30, 2020 at 10:03
  • Thanks for the input. I spend sometime understanding the build context. I have resolved the problem now. Please check answer Commented Oct 1, 2020 at 1:44

1 Answer 1

1

I have changed this into two stage build and solved it

#stage1 FROM adoptopenjdk/openjdk14:ubi as builder RUN mkdir build COPY . /build WORKDIR /build RUN chmod +x ./mvnw && \ ./mvnw package #stage2 FROM adoptopenjdk/openjdk14:ubi COPY --from=builder /build/q-runner/target/lib/* /deployments/lib/ COPY --from=builder /build/q-runner/target/*-runner.jar /deployments/app.jar ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 CMD java -jar /deployments/app.jar 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.