edbizarro / gitlab-ci-pipeline-php

:coffee: Docker images for test PHP applications with Gitlab CI (or any other CI platform!)
https://hub.docker.com/r/edbizarro/gitlab-ci-pipeline-php
MIT License
529 stars 167 forks source link

could not lock config file /root/.gitconfig: Operation not permitted #98

Closed alex1702 closed 4 years ago

alex1702 commented 4 years ago

I get the following error message: could not lock config file /root/.gitconfig: Operation not permitted

gitlab-ci.yml:

stages:
  - prod

deploy2prod:
  stage: prod
  environment: production
  image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  script:
    - sudo /my/private/path/deploy.sh
  only:
    - master
  tags:
    - srv01

Gitlab Output:

Running with gitlab-runner 13.2.2 (fedcba)
  on srv01-Docker-Runner abcdef
Preparing the "docker" executor
Using Docker executor with image edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Pulling docker image edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Using docker image sha256:66ddd6436954c6d91b9e48a90bcbb5297afdb9ee4fd73a0068ea2e444b846fcf for edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Preparing environment
00:05
Running on runner-abcdef-project-117-concurrent-0 via srv01...
Getting source from Git repository
00:02
error: could not lock config file /root/.gitconfig: Operation not permitted
ERROR: Job failed: exit code 1

Gitlab raw Output:

Running with gitlab-runner 13.2.2 (a998cacd)
  on srv01-Docker-Runner abcdef
section_start:1597038575:prepare_executor
Preparing the "docker" executor
Using Docker executor with image edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Pulling docker image edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Using docker image sha256:1a95806f1ce5c3bd21e0fcd2a36a45b76030e67eff418c7e3da5d27a3e454f87 for edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
section_end:1597038594:prepare_executor
section_start:1597038594:prepare_script
Preparing environment
Running on runner-abcdef-project-117-concurrent-0 via srv01...
section_end:1597038595:prepare_script
section_start:1597038595:get_sources
Getting source from Git repository
error: could not lock config file /root/.gitconfig: Operation not permitted
section_end:1597038597:get_sources
ERROR: Job failed: exit code 1

edbizarro commented 4 years ago

The image run as an user called php and do not have permission to write on the /root dir, but all sudo commands should run fine.

alex1702 commented 4 years ago

Yeah, OK. But that's being handled by gitlab-runner, not me. So how am I supposed to fix it if I can't control it?

edbizarro commented 4 years ago

from times to times the gitlab runners throws some weird errors like this one, try cleaning the gitlab ci cache by click on the UI button

alex1702 commented 4 years ago

Unfortunately, that didn't help either. Another idea? You can use gitlab-ci with your image?

edbizarro commented 4 years ago

hm, weird, can you share your full (ou relevant parts like before_script and such) .gitlab-ci.yml?

Yeah, i use it in all my php projects

alex1702 commented 4 years ago

It is the yml in the first post. I just adjusted the path to the script, because this is not for the eyes of the public. But just as a hint. The path is in /var/www and is also rw mounted on the gitlab-runner server.

And in the past the configuration worked like this.

alex1702 commented 4 years ago

Okay, I found the problem. My docker on the gitlab-runner server uses the storage driver aufs, but it seems to be causing problems. I changed it to overlay2 and it works. The server still runs with Ubuntu 16.04, maybe that's the reason.

You can find out the current Storage Driver with docker info.

Appropriate issue https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26618

And the instructions for changing the Storage Driver : https://docs.docker.com/storage/storagedriver/overlayfs-driver/

edbizarro commented 4 years ago

Oh i see, glad you found a solution!