Differences in cp Command Behavior Between Alpine and Debian-Based Docker Images
Key point
When using the cp command, symbolic link handling behaves differently between Alpine-based images and Debian/Ubuntu-based images.
Details
There is a difference in how the cp command behaves between Alpine and Debian/Ubuntu, which are frequently used as Base Images when building Docker images.
When running the cp command on a symbolically linked file in an Alpine-based image, the existing symbolic link is removed and the target file is copied as a new file.
On the other hand, in Debian or Ubuntu-based images, the symbolic link is preserved while the file's contents are copied, resulting in a phenomenon where the content of the original file ends up being changed.
Therefore, when migrating between these two environments, caution is needed to prevent unintended file modification, such as explicitly deleting the symbolic link with the rm command before running cp.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.