Reputation: 1516
I am trying to copy a jar file in my dockerfile. whne I run build, I can see the jar under target/dockerbuild. But docker does not see the file and I am getting following error.
COPY failed: no source files were specified
My docker file has those lines for copy operation:
ENV MY_HOME=/usr/local/myhome
COPY target/dockerbuild/my.jar $MY_HOME
Why it cannot find the jar although it exists under the target.
Upvotes: 1
Views: 9688
Reputation: 637
I had a very similar situation.
ls target/dockerbuild/my.jar
proofed that the file exists but docker build claimed that no source files were specified. However there also was a tiny hint that I did not notice for some time:
When using COPY with more than one source file, the destination must be a directory and end with a /
Though I only had one file I added the / to the copy destination and the build succeeded.
Upvotes: 0
Reputation: 275
Your error looks like it could be one of the following:
Please can you share what you run to build your docker image (so we can see the build context) and also your directory structure
Upvotes: 2
Reputation: 505
Verify that in your .dockerignore do not have that path (target) in your exceptions
Upvotes: 1
Reputation: 317
That error said file target/dockerbuild/my.jar
is not exist. The architecture of COPY in Dockerfile is:
COPY {file in your host} {path of target in docker image}
Upvotes: 0