3

I have directory csv in context directory of docker build. I want to copy it into docker image in all circumstances (for empty directory in host an empty directory inside image is created, for nonempty directory in host it is copied with all content).

The COPY csv/* /csv/ gives COPY failed: no source files were specified error when the directory is empty.

Similar questions I found on SO are differing from my case in either setup or intention (multistage build, copying existing jar, certainly existing file) so I choose Q&A-style here rather than messing question with unrelated answer. This Github issue is also related.

1 Answer 1

4

The solution is to use

COPY csv/. /csv/

This question gave me a hint (although the behavior desired by me is unwanted for its OP).

2
  • The more idiomatic way would be COPY csv /
    – super
    Dec 9, 2021 at 20:30
  • Interesting but empty directory fails on next Docker instruction ADD anothernonemptydir/** /anothernonemptydir/ with failed to export image: failed to create image: failed to get layer sha256:37e90a5f...: layer does not exist error; for nonempty directory it fails on later chmod (probably was not created either). Dec 9, 2021 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.