All new files and directories are created with a UID and GID of 0, unless the optional --chown flag specifies a given username, groupname, or UID/GID combination to request specific ownership of the copied content.
But when using kaniko the owner of the files is preserved when using COPY instead of using UID/GID of 0.
Expected behavior
The copied files must belong to root.
To Reproduce
Prepare the environment:
$ touch test
$ stat -c '%u' test
1000
$ cat Dockerfile
FROM alpine:3.19
COPY test /tmp
RUN [ "$(stat -c '%u' /tmp/test)" = "0" ] || exit 1
Actual behavior
According to the dockerfile reference of COPY https://docs.docker.com/engine/reference/builder/#copy
But when using kaniko the owner of the files is preserved when using COPY instead of using UID/GID of
0
.Expected behavior The copied files must belong to root.
To Reproduce
Prepare the environment:
Run with docker buildx: OK
Run with kaniko: FAIL
Additional Information
Provided in
To Reproduce
step.Triage Notes for the Maintainers
--cache
flag