SonarScanner config issue in Gitlab CI

Must-share information (formatted with Markdown):

  • SonarQube Docker image Community edition 8.7.0, Sonar Scanner latest image
  • I have setup sonarqube in a docker container. After adding the sonar-check stage in Gitlab CI, the scanner is not executing the stage properly. Gitlab Runner is running on the docker environment.
    following error is being thrown:
    /bin/bash: line 118: docker: command not found
    My guess runner is trying to execute the docker info command inside sonarscanner docker image.

Steps to reproduce:

  1. Setup ur project on sonarqube.
  2. Configure Analysis with Gitlab CI
  3. Build Technology Other
  4. Configure file
  5. Add other environment variables
  6. Copy gitlab configuration from sonarqube, paste it in .gitlab-ci.yml file.

Hi, welcome to the community forum.

If I understand correctly, you are running Gitlab Runner in a docker container, and try to use the docker scanner image. That means that your dockerized Gitlab Runner needs to be able to spawn other docker containers, with a privileged mode.

If my understanding is correct, then what you need is to enable the dind service, for Docker IN Docker. Documentation is here

yup sure, thanks, I will try this.

Unfortunately same error, even though my runners are running in privileged mode and I have added the
- docker:dind
line in my gitlab yml file

Could we have a look at your .gitlab-ci.yml job?

    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
    - docker:dind
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
    key: "${CI_JOB_NAME}"
      - .sonar/cache
    - sonar-scanner
  allow_failure: true
    - master # or the name of your main branch

My Gitlab Job