Open dereckson opened 2 years ago
I feel the situation here is ambiguous. There are two possible things the user could mean:
Without a flag to COPY
or something, there's no way to know what the intent was. This is similar to the issue I described in #1260. Curiously, in that case symlinks to files got followed, but that logic evidently is not applied to symlinks to directories.
A separate yet related issue is the matter of COPY
ing a directory onto a file (or vice versa), which buildkit does not allow.
There are several other issues with symbolic links, but I'm not sure this one has already been reported.
An image provides a directory structure including a
files/etc/service
folder.The /etc/service path already exists on the image at that step, but as a symbolic link.
The legacy build mode is happy to supersede the symlink by a directory, without any warning. BuildKit fails with a decent error message "cannot copy to non-directory" (decent enough it's easy to understand /etc/service existed, and not as a directory).
On a legacy build, the image will be correctly built and the container has a folder:
A third scenario, not chosen by neither, could have been keep the symlink, follow it and populate target directory. That could lead to an image providing a full directory conf.d with the expectation it's only those files, to finally share them with previous existing files, because of the symlink.
Not sure the best approach on this one, could clearly be raise an error on legacy build mode instead of propagating a bug-as-a-feature into BuildKit.