reesaspieces
reesaspieces

Reputation: 1800

Cannot use git while docker is up

I have a strange situation where I can't use most git commands while Docker containers are running. As soon as I stop the Docker containers, I can use git normally again. Any suggestions for what could be causing the issue?

Errors:

$ git checkout master
fatal: Unable to create '/Users/me/project/.git/index.lock': Operation not permitted
$ git rebase -i head~2
error: could not create temporary .git/rebase-merge: Operation not permitted
$ git pull
fatal: update_ref failed for ref 'ORIG_HEAD': cannot lock ref 'ORIG_HEAD': Unable to create '/Users/me/project/.git/ORIG_HEAD.lock': Operation not permitted

Upvotes: 2

Views: 709

Answers (1)

Jerven Clark
Jerven Clark

Reputation: 1219

As @LeiYang pointed out, I also think your git directory is being mounted. If you're using docker-compose.yml you can mount your project's root directory while ignoring git by creating a secondary anonymous volume like so:

volumes:
  - .:/app/
  - /app/.git/

Although, a better approach would be to not mount your entire project's root dir but only the src or the directories needed for your project to run

Upvotes: 2

Related Questions