Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

I'm using an image container that consists of a git repository, X. Every week I'm doing build & push and create a new tag for this image, and on my Jenkinsfile, I'm using the specific updated tag at each time.

What I do in my docker file is simply git clone to the repository X, and then chmod -R 777 to the whole repository.

Now I want to access this image from my build process (I'm writing it with Jenkinsfile), but when I do it and try to operate any git commands on this repository I get the following error:

could not lock config file filepath/../.git/config :permission denied

Any suggestions here?

I've provider chmod -R 777 to all files, then i'm not sure why I receive this error.

"root" is the user who performed this clone, and "root" is the user in the running slave who is trying to access this git repository. So I'm not sure if the issue is the user who cloned the repo.

My Dockerfile is as follows:

RUN yum install -y git

RUN git clone X

RUN chmod -R 777 /home/appuser/X

RUN sudo chown $(whoami) -R /home/appuser/X/.git

1 Answer

0 votes
by (12.4k points)

Here it seems your ".git/config" file is owned by the root user and thus gives the permission error when you lock it.

sudo chown bhishan -R .git from the ~/Copy/try directory 

this should fix the permissions issue.

For more information on Git, you can join git training.

To know more about git commands, check out:

Browse Categories