I tried the following command in my Dockerfile: COPY * /
and got mighty surprised at the result. Seems the naive docker code traverses the directories from the glob
As mentioned in your ticket:
You have
COPY files/* /test/
which expands toCOPY files/dir files/file1 files/file2 files/file /test/
.
If you split this up into individualCOPY
commands (e.g.COPY files/dir /test/
) you'll see that (for better or worse)COPY
will copy the contents of each argdir
into the destination directory. Not the argdir
itself, but the contents.I'm not thrilled with that fact that COPY doesn't preserve the top-level dir but its been that way for a while now.
so in the name of preserving a backward compatibility, it is not possible to COPY
/ADD
a directory structure.
The only workaround would be a series of RUN mkdir -p /x/y/z
to build the target directory structure, followed by a series of docker ADD
(one for each folder to fill).
(ADD
, not COPY
, as per comments)