Files
kaniko/integration/dockerfiles/Dockerfile_test_workdir_with_user
T
Aris Buzachis 61312a95ae fix(WORKDIR): use the config.User for the new dir permissions (#2269)
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>
2022-09-28 21:18:40 -04:00

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