how to clone without root on gitlab-runner docker

I’m trying to create a ci pipeline for my code. I have registered a runner with docker executor in my machine. I noticed it is cloning the repository with root privileges inside the docker container

$ ls -l
total 4
drwxrwxrwx 4 root root 4096 Jan  3 18:02 my-repo

Thus, to build the content on my repo I must run some commands with sudo from my .gitlab-ci.yml and I don’t want that.

Is there a way to tell gitlab-runner to clone the repository with user privileges?

1 Like