CodexBloom - Programming Q&A Platform

GitLab CI/CD: Job scenarios with 'Permission Denied' When Accessing Docker Socket in Runner

👀 Views: 41 💬 Answers: 1 📅 Created: 2025-06-03
gitlab ci-cd docker YAML

I've hit a wall trying to I'm currently working with an scenario with my GitLab CI/CD pipeline where a job fails due to a 'Permission Denied' behavior when trying to access the Docker socket. I have the following job defined in my `.gitlab-ci.yml`: ```yaml stages: - build build_image: stage: build image: docker:latest services: - docker:dind variables: DOCKER_DRIVER: overlay2 script: - docker info - docker build -t my-image:latest . ``` The job fails with the following behavior message: ``` behavior: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/create?fromImage=my-image&tag=latest": dial unix /var/run/docker.sock: connect: permission denied ``` I made sure that the GitLab Runner is running with the `--privileged` flag and that it is set to use the Docker-in-Docker (dind) service. Here’s how I’ve registered the runner: ```bash gitlab-runner register --executor docker --docker-image docker:latest --docker-privileged ``` Additionally, I've checked the runner’s configuration in `config.toml`: ```toml [[runners]] name = "docker-runner" url = "https://gitlab.com/" token = "YOUR_TOKEN" executor = "docker" [runners.docker] tls_verify = false image = "docker:latest" privileged = true disable_entrypoint_overwrite = false oom_kill_disable = false ``` I’ve also attempted modifying the permissions on the socket by adding the runner to the `docker` group. However, the job still fails with the same permission behavior. I’m wondering if there are additional configurations or troubleshooting steps I might be missing to allow the runner to access the Docker daemon properly. Any insights would be appreciated! Am I approaching this the right way?