Archive · DevOps

SonarQube 10.4: Install with Docker Compose

Run SonarQube Community Edition with PostgreSQL, including the kernel settings it needs.

1 min read

  • SonarQube 10.4 Community
  • PostgreSQL 15
  • Docker Compose 2.24

SonarQube is an Elasticsearch-based service, so the host needs these kernel settings first:

sudo sysctl -w vm.max_map_count=524288 fs.file-max=131072
echo "vm.max_map_count=524288" | sudo tee -a /etc/sysctl.d/99-sonarqube.conf
echo "fs.file-max=131072"      | sudo tee -a /etc/sysctl.d/99-sonarqube.conf

docker-compose.yml:

services:
  sonarqube:
    image: sonarqube:10.4-community
    depends_on: [db]
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: ${SONAR_DB_PASSWORD}
    ports: ["9000:9000"]
    volumes: [sq_data:/opt/sonarqube/data, sq_ext:/opt/sonarqube/extensions, sq_logs:/opt/sonarqube/logs]
  db:
    image: postgres:15
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: ${SONAR_DB_PASSWORD}
      POSTGRES_DB: sonar
    volumes: [pg_data:/var/lib/postgresql/data]
volumes: { sq_data: , sq_ext: , sq_logs: , pg_data: }

Open port 9000, sign in as admin / admin and change the password immediately. Give it at least 4 GB of RAM. The Community Edition analyses one branch and no pull requests; those features are in the paid editions.