git-clone fails when current user is not in /etc/passwd
- From
Taylor Braun-Jones <taylor@braun-jones.org>
- Date
- Dec 2, 2015, 20:10 UTC
- Message-ID
- <CAKfKJYsyHn7FUOu65AqbvjZD-wAyRScjqUL6kgGDCVzG1myZTQ@mail.gmail.com>
My use case it running git clone inside a docker container with `docker run --user $(id -u):$(id -g) --volume /foo:/foo ...`. I want all /foo/* file creation/access from inside the Docker container to be done as the current uid/gid of the host system.
Steps to reproduce:
mkdir /tmp/docker-git cat > /tmp/docker-git/Dockerfile <<EOF FROM ubuntu RUN apt-get update && apt-get install -y git-core EOF docker build -t git /tmp/docker-git/ docker run --user $(id -u):$(id -g) git git clone https://github.com/git/git.git /tmp/git # fatal: unable to look up current user in the passwd file: no such user echo $? # 128
My current workaround is:
cat >> /tmp/docker-git/Dockerfile <<EOF RUN git config --system user.name Docker && git config --system user.email docker@localhost EOF
But I don't see why this should be necessary just to clone a repo. I run complex build jobs inside a docker container using this approach and git-clone is the first command to fail due to the lack of a passwd file entry for the current user. Some complain to stderr, but still succeed.
Regards, Taylor