user1474111
user1474111

Reputation: 1516

Docker Copy failed no source files were specified

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

Answers (4)

r-uu
r-uu

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

JasonS
JasonS

Reputation: 275

Your error looks like it could be one of the following:

  • The file doesn't exist in the specified path
  • The path doesn't exist (relative to the build context - if you use 'docker build .' then the specified path must exist relative to the current directory)

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

Luisao
Luisao

Reputation: 505

Verify that in your .dockerignore do not have that path (target) in your exceptions

Upvotes: 1

GreenMan
GreenMan

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

Related Questions