mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-05 11:21:10 +02:00
WORKDIR ignores the currently set USER and creates the new directories with the root user ownership. This changes that, by executing a chown after the mkdir if needed, and also handle the case where the provided USER is an uid and the passwd file is not available to resolve to the username. Fixes #2259 Signed-off-by: Aris Buzachis <buzachis.aris@gmail.com> Signed-off-by: Aris Buzachis <buzachis.aris@gmail.com>
42 lines
659 B
Plaintext
42 lines
659 B
Plaintext
FROM debian:9.11
|
|
RUN groupadd -g 10000 bar
|
|
RUN useradd -c "Foo user" -u 10000 -g 10000 -m foo
|
|
|
|
|
|
# no passwd file
|
|
FROM scratch
|
|
|
|
# without a USER Set
|
|
WORKDIR /workdir/wo/user
|
|
|
|
USER 9999
|
|
WORKDIR /workdir/w/uid
|
|
|
|
USER 9999:9999
|
|
WORKDIR /workdir/w/uid_gid
|
|
|
|
USER 0
|
|
WORKDIR /workdir/w/root_uid
|
|
|
|
USER root
|
|
WORKDIR /workdir/w/root_username
|
|
|
|
# with passwd file
|
|
COPY --from=0 /etc/passwd /etc/passwd
|
|
COPY --from=0 /etc/group /etc/group
|
|
|
|
USER foo
|
|
WORKDIR /workdir/w/foo_username
|
|
|
|
USER foo:10000
|
|
WORKDIR /workdir/w/foo_username_gid
|
|
|
|
USER 10000
|
|
WORKDIR /workdir/w/foo_uid
|
|
|
|
USER 10000:10000
|
|
WORKDIR /workdir/w/foo_uid_gid
|
|
|
|
USER 10000:bar
|
|
WORKDIR /workdir/w/foo_uid_groupname
|