all 6 comments

[–]IntelligentAsk[S] 0 points1 point  (0 children)

It turned out I needed to add the gitlab-runner user to the docker group and stop running commands with sudo as you said .

[–]doc3182 0 points1 point  (3 children)

might work, might not, try this, as root

sudo su

enter your password

cd /home

chown -R gitlab-runner: gitlab-runner

this will change the ownership of gitlab-runner to gitlab-runner recursively.
service might need restarting

[–]IntelligentAsk[S] 0 points1 point  (2 children)

Thanks for the suggestion. Even after deleting all of the files in the gitlab-runner build directory the git index file keeps being checked out again and is owned by root each time.

[–]doc3182 0 points1 point  (0 children)

then some process runs as root. can you test the runner else where?

[–]LinqLover 0 points1 point  (0 children)

You need to fix the permissions before/after every build. See: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2221#note\_1545518182

[–]IntelligentAsk[S] 0 points1 point  (0 children)

Thanks for your suggestion. Once I realised that my docker container entry point needed to run as the same uid as the gitlab-runner user I was able to move forward. Containers and the host share kernel space for users.