My container was built to start with a non root user instead of root. However the runner wants to access /builds in the container and the container's user doesn't have access. Not sure what to do as I don't want to rebuild my image with root access only.
We really need to change this. We had several issues running npm, bower, grunt as root. actually i change the user manually in my .gitlab-ci.yml file, because otherwise i need to add some parameters --allow_root, ...
I did not use git clone or git fetch in my CI config.
However, my rake spec task does use git clone to pull down a bunch of repositories for testing, which some of these repositories are private and require a key.
i created a new docker image with a /build folder as you suggested. Even if i give this folder the permission of chmod 777 /build it fails with the error:
gitlab-ci-multi-runner 0.4.2 (1e86428)Using Docker executor with image my-centos:7 ...mkdir: cannot create directory '/builds/daniel.widerin/my.project': Permission deniedbash: line 5: /builds/daniel.widerin/my.project.sh: Permission deniedBuild failed with exit code 1
What do you mean with VOLUME, is the checkout volume linked?
can you guide me to the code fragment which instanciates the docker container, maybe i can find the exact issue easier.
BTW, starting a docker container of the given image succeeds, and since i assign 777 as permission i have no clue how this error can happen:
I think part of the problem is that you placed USER somebody at the bottom of the dockerfile. You need to place it around line 56 and then all the chowning and chmoding is not necessary because it is created under the user.
@cosman2001@widerin I did it! No more hacks are required in Dockerfile. The /builds/group-name will have chmod 777 when creating cache container, that cache container is then attached to build container. Please upgrade to bleeding edge and test if it works ok. It effectively resolves the issue for me.
This way git clone works, but it did not work when I switched back to git fetch. I think that's because the cache container already had the project build directory and it belonged to root. I cleared the cache containers like this, and now it works.
I made a test script which shows the permissions of the directories, and tried it out with the git clone and git fetch setting on CI.
This was the result:
So this suggests that it only mounts the cache volume if you use git fetch, and it becomes root:root because of that (/builds is still cirunner:cirunner).
@cosman2001 the complexity of my Dockerfile comes from ADD command of docker, because all added files are owned by root by default, even if you add them after setting a user by a USER command.
So if you want to copy a key inside your image, i did not found a simpler way to do so than chown and chmod the keyfile, any suggestions?
Is there a way yet to change the user outside of the Dockerfile? I'm using an official Dockerfile from the registry, and I don't have the ability to change it.
@DaAwesomeP if this Dockerfile gives you root permissions you can switch to any user you want in your test script by using su - <username>.
Anyway, this is not related to this issue.