Error 'su: unknown user gitlab-runner' when running gitlab-runner as a docker image
Starting after v1.4.2, the entrypoint for gitlab-runner was changed to dumb-init, using parameter --user=gitlab-runner.
When this change was introduced, running gitlab-runner as a docker image no longer works, because the user does not exist in the container. It worked previously because the process ran as root.
We are working around it by making a derived container, and removing --user=gitlab-runner from the CMD, like so:
CMD ["run", "--working-directory=/home/gitlab-runner"]
It is not the end of the world, we would probably override the base image anyway, because that is how we avoid installing custom binaries on the VM running our runners. But it still took a bit to figure out.
As a solution, I would recommend that the docker container add a gitlab-runner user, and that this user be added to the docker group.
This will be the fix that most people want. The out-of-the box runner will work as a docker image again. The docker group part is needed for people like us who are using the docker command line in the runner image. For this use case, we need to be root so we can access the docker socket mounted on /var/run/docker.sock.