Getting error while copying .jar from host to container in Dockerfile

We are setting up CI-CD using Gitlab with shell as an executor and created a specific runner We have 2 stages in gitlab-ci.yml file :

stages:

  • build
  • image-build

build:
stage: build
script:
- echo $JAVA_HOME
- mvn clean install
stage: build
when: manual

image-build:
stage: image-build
before_script:
- docker info
script:
- docker build -t hci-maven .
stage: image-build
when: manual

------------------------------------------------------------------------------------------------------------------------and Dockerfile -

FROM tomcat

COPY target/back-office-1.0.54.jar /usr/local/tomcat/webapps/

EXPOSE 8080

In stage 1, we are able to build a jar file but when we are trying to create a docker image from stage 2… we are getting this error… Actually .jar is creating in target folder but it’s looking in docker daemon directory /var/lib/docker/tmp

"Step 2/4 : COPY office.jar /usr/local/tomcat/webapps/

COPY failed: stat /var/lib/docker/tmp/docker-builder602934788/office.jar: no such file or directory"

Please help me resolve this issue.

Thanks
Anuj Gupta

i am having a similar problem. Did you ever figure this out?
I want to copy a file from /myhost/dir to my docker images but its looking in /var/lib/docker/tmp/docker-builder566275746