HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavadockerMinor

How to change Xmx settings for sonar runner?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
settingsrunnerforsonarhowchangexmx

Problem

This Question has been answered on Stackoverflow too.

I have a Sonarqube instance running as a docker container. Since I updated it to version 7.1 the analysis of my greatest project fails with GC limit exceeded. If I restart the server, it might succeed once. After a while of researching this issue, I am tempted to believe, I need to increase the Xmx value for the background task.

Where and how can I configure this parameter?

docker-compose.yml

version: "2"
services:

  postgres:
    image: postgres:9-alpine
    container_name: postgres
    restart: always
    volumes:
      - /opt/docker-postgres/etc:/etc/postgresql
      - /opt/docker-postgres/log:/var/log/postgresql
      - /opt/docker-postgres/data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: sonar
      POSTGRES_USER: 
      POSTGRES_PASSWORD: 

  sonar:
    image: sonarqube:alpine
    container_name: sonar
    restart: always
    ports:
      - "9000:9000"
      - "9092:9092"
    environment:
      SONARQUBE_JDBC_USERNAME: 
      SONARQUBE_JDBC_PASSWORD: 
      SONARQUBE_JDBC_URL: jdbc:postgresql://postgres/sonar
    volumes:
      - /opt/docker-sonar/conf:/opt/sonarqube/conf
      - /opt/docker-sonar/data:/opt/sonarqube/data
      - /opt/docker-sonar/extensions:/opt/sonarqube/extensions
      - /opt/docker-sonar/bundled-plugins:/opt/sonarqube/lib/bundled-plugins

Solution

You can simply put a sonar.properties file under /opt/docker-sonar/conf/. This file will be available inside the container under /opt/sonarqube/conf/, because the folder gets mounted as volume.

A full example for a sonar.properties file can be found on github. However all you need to enter is:

sonar.ce.javaOpts=-Xmx -XX:+HeapDumpOnOutOfMemoryError

Code Snippets

sonar.ce.javaOpts=-Xmx<XMX_VALUE -Xms<XMS_VALUE> -XX:+HeapDumpOnOutOfMemoryError

Context

StackExchange DevOps Q#4106, answer score: 2

Revisions (0)

No revisions yet.