Open linusyong opened 1 year ago
"Hard link detection is hard."[tm]
For reference:
--preserve=links
to detect and preserver hard links)COPY
preserves hard linksAs a workaround, you could tar
the directory in the first stage, copy that archive and untar
in the next stage (yes, I know, not pretty)
Actual behavior The hard link files' data storage during
COPY
is replicated, making the resulting container image much larger.Expected behavior The
COPY
operation should replicate the hard link with a single copy of underlying storage.To Reproduce Steps to reproduce the behavior:
Create a
Dockerfile
docker build
Perform a build with
kaniko
size
of the container image is very different:Additional Information
Dockerfile
Build Context N.R.
Kaniko Image (fully qualified with digest)
sha256:d3669fd5e0e91893ba652b93134ff66c22e34f5a88c9e023ae84c84f26cddaea
This mutlistage built base on
bitnami/git:2.41.0-debian-11-r6
(sha256:120c692378b9ddb77a895271bdda03d0f1b6d1fbf16f991c8d73c73a71b4d2a4
). If we check the/opt/bitnami/git/libexec/git-core/git
file, it is a hard link file:Using the
docker build
built container image, it demonstrate the same behavior:Using
Kaniko
built container image, the hard link is removed with the inode referencing to a single copy of dataTriage Notes for the Maintainers
--cache
flag