From 42916b0142cc0d43808418faec59ea45ddfbd535 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sun, 11 Sep 2022 00:57:53 -0400 Subject: [PATCH] Use fixuid to resolve user perm conflicts in mounted dirs It matches the user permissions in the container to those in the host. This has clear advantages to our previous solution, which matched the permissions in the image. One immediate benefit is that the jenkins server-build node can pull the image from Docker Hub, rather than build it on the host (for each build, to ensure the image is up-to-date). --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4c95ae2..537a0e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -296,10 +296,20 @@ RUN \ ######################## ARG docker_user -ARG docker_user_id ARG docker_password RUN \ - useradd -u $docker_user_id -m $docker_user \ - && echo "${docker_user}:${docker_password}" \ - | chpasswd && adduser $docker_user sudo + useradd -m $docker_user \ + && echo "${docker_user}:${docker_password}" | chpasswd \ + && adduser $docker_user sudo + +RUN USER=$docker_user && \ + GROUP=$docker_user && \ + curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ + chown root:root /usr/local/bin/fixuid && \ + chmod 4755 /usr/local/bin/fixuid && \ + mkdir -p /etc/fixuid && \ + printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml + +USER $docker_user:$docker_user +ENTRYPOINT [fixuid]