Code-quality is failing on privileged runner

I’m trying to run Code Quality job. I’m using a private runner and I set it up for Docker-in-Docker workflow as it is described in Gitlab documentation. I set the privileged = true in runner configuration. I’m running it on a linux server as root user. However I’m getting 2 sets of error:

  1. When it starts service docker:20.10.12-dind I get Health check error

Starting service docker:20.10.12-dind …
.
.
.
Waiting for services to be up and running…

*** WARNING: Service runner… probably didn’t start properly.

Health check error:

  • service “runner-…-project-4-concurrent-0-ee4c38ab9fd2a2ca-docker-0-wait-for-service” timeout
  • Health check container logs:
  • Service container logs:
  • ip: can’t find device ‘ip_tables’
  • ip_tables 27126 2 iptable_nat,iptable_filter
  • can’t change directory to ‘/lib/modules’: No such file or directory
  • mount: permission denied (are you root?)
  • Could not mount /sys/kernel/security.
  • AppArmor detection and --privileged mode might break.
  • mount: permission denied (are you root?)
  1. Then it continues running the script in code quality template but throws the second error when it reaches out to this line

$ docker pull --quiet “$CODE_QUALITY_IMAGE”

error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

All issues and documentation say setting privileged = true should fix the issue but in my case it doesn’t.