使用一个命令复制多个目录

使用一个命令复制多个目录

问题描述:

有没有一种方法可以在一个命令中复制多个目录以减少层数?例如,而不是:

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

我想这样做:

COPY dirone/ dirtwo/ dirthree/ ./

这会复制目录的内容 ...但是我想复制目录本身的

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

这是复制命令的记录行为:

That's the documented behavior of the copy command:


如果< src> 是目录,将复制目录的整个内容,包括文件系统元数据。

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.