Deploy SonarQube using Dockers in macOS

Alejandro Sejas
3 min readDec 21, 2020

How to deploy a Production SonarQube environment using Dockers with a persistent volume in macOS

https://www.sonarqube.org/logos/

Install Docker Desktop

  1. Download Docker Desktop from its official site: https://www.docker.com/products/docker-desktop
  2. Install the app and run it

Download and Deploy SonarQube containers

  1. Download and save the following .yaml file in any folder: https://github.com/alejandrosejas/sonarQubePersistentVolume
  2. Open a Terminal window in the folder where the file was saved and execute the following command: “docker-compose up -d
  3. Wait until the process is finished and you should see now the SonarQube containers in the Docker Desktop app.

4. Open a new browser window and navigate to http://127.0.0.1:9000/

You should see the SonarQube server running and with persistent data (which allows you to save all data even if the container is restarted).

Add SonarQube Scanner files into the OS Path folder

  1. Go to https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
  2. Select the scanner files you need to download according to the OS you are currently running. In this case macOS
  3. Download and Unzip SonarScanner folder
  4. Save it in any Folder

5. Open a new Terminal window

6. Run: “sudo nano /etc/paths”

7. Add the path where the SonarScanner is located and save the file.

Adding a new Project to the SonarQube server

  1. Click on ‘Create New Project’
  2. Give it a Project Key and click ‘Set Up’
  3. Enter a new token name and Click Generate and Continue
  4. Select the Project’s main language
  5. Select the OS where the source is located
  6. Run the generated Console code inside the folder where the project is.

7. Once the code is executed in the Terminal, return to the SonarQube server

8. SonarQube will display the scan results

Now you should have a persistent volume of SonarQube running in your machine and have already scanned a project.

--

--