For quickly setting up Sonarqube and run a scan on your Java code, do the following.
$ docker run -ti sonarqube:lts
$ docker ps -q |
xargs docker inspect --format='{{range $n, $c := .NetworkSettings.Networks}}{{$c.IPAddress}}{{end}}'
172.17.0.2
Run the Sonarqube scan and post the results to the process in the Docker container.
$ mvn sonar:sonar -Dsonar.host.url=http://172.17.0.2:9000
Point your web browser at http://172.17.0.2:9000
If you want a Docker cluster with Sonarqube and Postgres, download this docker-compose from the Sonarqube Docker repository, and run:
$ sudo sysctl -w vm.max_map_count=262144
$ docker-compose up
To make the kernel setting permanent:
# cat >> /etc/sysctl.d/99-sonarqube.conf <<EOF
# Needed by Sonarqube/Elastic search
vm.max_map_count=262144
EOF
The promise of doing all of this in 5 minutes depends on the speed
on your network connection, your computer and last but not least: the
size of your Java project 😄
Happy security scanning!