From 80042bd00f5acdd579196914c51e58bf9c473444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey?= Date: Wed, 19 Apr 2017 18:10:56 +0200 Subject: [PATCH] Ensure build user has the same UID and GID as the host user This prevents permission problems since volum owners are set from host --- Dockerfile | 8 +++++++- run.sh | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3bf92bf..95236eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,13 @@ RUN apt-get install -y android-tools-adb android-tools-fastboot RUN apt-get install -y bc bsdmainutils file screen RUN apt-get install -y bash-completion wget nano -RUN useradd build && rsync -a /etc/skel/ /home/build/ +ARG hostuid=1000 +ARG hostgid=1000 + +RUN \ + groupadd build -g $hostgid && \ + useradd build -g $hostgid -u $hostuid && \ + rsync -a /etc/skel/ /home/build/ RUN mkdir /home/build/bin RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /home/build/bin/repo diff --git a/run.sh b/run.sh index 6d2ff49..475417f 100755 --- a/run.sh +++ b/run.sh @@ -48,7 +48,9 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then docker pull ubuntu:16.04 echo "Building Docker image $REPOSITORY:$TAG..." - docker build -t $REPOSITORY:$TAG . + USERID=$(id -u) + GROUPID=$(id -g) + docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID . OK=$? # After successful build, delete existing containers