From 12f8f48f56c223060dccfed0fa2d1f49c8e2bf09 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Thu, 5 Apr 2018 11:35:29 +0200 Subject: [PATCH] fix: use host user UID and GID Avoid permission errors for mounted volumes and also created files on the host. --- docker/Dockerfile | 4 +++- docker/build | 2 +- docker/run | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e619666..7faae5d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,10 +14,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ less \ && rm -rf /var/lib/apt/lists/* +ARG UID=1000 +ARG GID=1000 ENV USER pytfa ENV HOME /home/$USER -RUN useradd -ms "/bin/bash" "$USER" +RUN groupadd -g "${GID}" "$USER" && useradd -u "${UID}" -g "$USER" -ms "/bin/bash" "$USER" USER $USER WORKDIR $HOME diff --git a/docker/build b/docker/build index 0b900ea..81704d3 100644 --- a/docker/build +++ b/docker/build @@ -1,2 +1,2 @@ #!/bin/sh -docker build -t pytfa_docker . +docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t pytfa_docker . diff --git a/docker/run b/docker/run index 791d716..316fd9d 100644 --- a/docker/run +++ b/docker/run @@ -1,5 +1,5 @@ #!/bin/sh -docker run --rm -it \ +docker run --rm -it \ -v $(pwd)/work:/home/pytfa/work \ -v $(pwd)/..:/src/pytfa \ pytfa_docker