Docker COPY and keep directory

Viewed 4655

Need to copy multiple directories in my Dockerfile. Currently, I'm doing:

COPY dir1 /opt/dir1
COPY dir2 /opt/dir2
COPY dir3 /opt/dir3

I would prefer to consolidate those into one single statement, specifying all the sources in one go. However, this way the contents are copied, and I lose the dir1, dir2, dir3 structure:

COPY dir1 dir2 dir3 /opt/

Same in this case:

COPY dir1/ dir2/ dir3/ /opt/

Is there some way to achieve this with one line?

1 Answers
Related