Copy multiple directories with one command

Claudiu picture Claudiu · Jun 9, 2016 · Viewed 28.5k times · Source

Is there any way to copy multiple directories in one command, to reduce the number of layers? E.g., instead of:

COPY dirone ./dirone
COPY dirtwo ./dirtwo
COPY dirthree ./dirthree

I want to do:

COPY dirone/ dirtwo/ dirthree/ ./

However, this copies the contents of the directories... but I want to copy the directories themselves.

Answer

BMitch picture BMitch · Jun 9, 2016

That's the documented behavior of the copy command:

If <src> is a directory, the entire contents of the directory are copied, including filesystem metadata.

Note: The directory itself is not copied, just its contents.

Best workaround I can suggest is to change your directory layout in your build folder, move the three folders under one parent folder and add the parent.