-
I have launched a RHEL8.5 VM to use as a GitLab runner with the docker executor pointing to the podman socket. It seems to work very well, thanks to the amazing work on the compat endpoints. However there's one kind of job that doesn't work unless you disable SELinux, the one which requires binding the "docker" socket to the container. For instance, Code Quality without dind (dinp?). I've found out that launching podman containers with Still, changing SELinux from enforcing to permissive has allowed the pipeline to succeed so maybe all this setup needs is a custom selinux policy? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
If you allow a container to talk to any UNIX domain socket on the host, SELinux will rightly block this and you will need to disable SELinux enforcement. We definitely do not want to allow SELinux confined containers to talk to the docker daemon or the podman system service. |
Beta Was this translation helpful? Give feedback.
-
security_opt = ["label=disable"] to [runners.docker] doesn't, not sure how to debug that. |
Beta Was this translation helpful? Give feedback.
-
Ok, I think I see what's happening now. Looking into the code quality job yaml and SELinux audit log I can infer the What is funny is that, aside from denying access to the podman socket SELinux is also blocking access to files from that host mount:
With So I decided to do some sanity checks: # /home/gitlab-runner/builds/scuZ-oAf/0/foo
# podman run -eDOCKER_HOST=unix:///var/run/docker.sock -v /var/run/docker.sock:/var/run/docker.sock -v $PWD:/code --rm --security-opt label=disable docker run --rm -v /code:/code alpine touch /code/bar
touch: /code/bar: Permission denied # cd /tmp/builds/scuZ-oAf/0/foo
# podman run --rm -v$PWD:/foo -ti alpine touch /foo/bar
touch: /foo/bar: Permission denied Interesting. Looks like the container spawned by the job script won't get the If the mount behavior is working as intended then I guess there's nothing wrong from the podman side. Actually, now that I took the time to look into this I'm wondering why that job uses dind at all... |
Beta Was this translation helpful? Give feedback.
-
I was facing the same issue. I have posted solution on GitLab Runner issue tracker: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3491#note_2233675636 In short:
[[runners]]
[runners.docker]
security_opt = ["label:disable"] It is not a perfect solution because it lowers security layer (for volumes used by CI jobs as cache) but much better than disabling whole SELinux protection. |
Beta Was this translation helpful? Give feedback.
If you allow a container to talk to any UNIX domain socket on the host, SELinux will rightly block this and you will need to disable SELinux enforcement. We definitely do not want to allow SELinux confined containers to talk to the docker daemon or the podman system service.