Sonarqube Developer won't start with Volume-Mounts in Docker

Whenever i try to start a Sonarqube Developer Docker Container, i get the following Errors:

  • main ERROR Unable to create file /opt/sonarqube/logs/es.log java.io.IOException: Permission denied
  • ERROR es[][o.e.b.ElasticsearchUncaughtExceptionHandler] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Unable to access 'path.logs' (/opt/sonarqube/logs)
  • java.lang.IllegalStateException: Unable to access 'path.logs' (/opt/sonarqube/logs)
    (also in that Order)

It seems like, Sonarqube can’t access any paths that are mounted to a Docker Volume.

This is the Compose Stack:

version: '3.6'

volumes:
  sonarqube-db-db:
  sonarqube-db-data:
  sonarqube-data:
  sonarqube-extensions:
  sonarqube-logs:

networks:
  int-sonarqube:

services:

  Sonarqube-DB:
    image: postgres:13
    hostname: sonarqube-db
    container_name: Sonarqube-DB
    environment:
      POSTGRES_USER: ${PGSQL_USER}
      POSTGRES_PASSWORD: ${PGSQL_PASSWORD}
      POSTGRES_DB: ${PGSQL_DB}
    volumes:
      - sonarqube-db-db:/var/lib/postgresql:rw
      - sonarqube-db-data:/var/lib/postgresql/data:rw
    networks: [int-sonarqube]
  
  Sonarqube:
    image: sonarqube:9-developer
    hostname: sonarqube
    container_name: Sonarqube
    depends_on: [Sonarqube-DB]
    networks: [int-sonarqube]
    ports:
      - ${SONAR_PORT}:9000
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://sonarqube-db:5432/${PGSQL_DB}
      SONAR_JDBC_USERNAME: ${PGSQL_USER}
      SONAR_JDBC_PASSWORD: ${PGSQL_PASSWORD}
    volumes:
      - sonarqube-data:/opt/sonarqube/data:rw
      - sonarqube-extensions:/opt/sonarqube/extensions:rw
      - sonarqube-logs:/opt/sonarqube/logs:rw 

Docker File was derived from official Example at GitHub: docker-sonarqube/example-compose-files/sq-with-postgres/docker-compose.yml at master · SonarSource/docker-sonarqube (github.com)

I already tried different “Modes” for the Volumes. “rw”, “z”, nothing. Even tried “ro” to maybe provoke a different error, but no such luck.

I also ran those commands on the Host Machine based on the Official Documentation:

  • sysctl -w vm.max_map_count=524288
  • sysctl -w fs.file-max=131072
  • ulimit -n 131072
  • ulimit -u 8192

I do not really understand what i’m doing wrong here, can anyone help?

Hi,

Welcome to the community!

Two questions. First, your compose stack is “derived” from the official example. What happens when you run the official example?

Second,

Shouldn’t this be 9.9.4-developer?

 
Ann

Hello,

yes, i also tried the official Example. Didn’t work either with same Error.

Regarding the Version: I got the specific requirement for Sonarqube 9…

What i also tried was mounting the entire /opt/sonarqube Directory to a Volume, which did actually work.
So instead of 3 seperate Mounts, just one.

I’m not completley sure why this is working, but it seems like thats what i’ll be going with

Hi,

If this actually is 9.0, then you need to know that your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

9.0 → 9.9.4 → 10.4 (last step optional)

You may find these resources helpful:

 
Ann

I have the same problem.

For me, the only way I can make it work is to remove all three 3 volume maps which defeats the purpose of having persistent settings. I can see that the service can create the 3 folders (data, logs, extensions) but cannot write anything inside.

2024.03.13 04:28:34 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024-03-13 04:28:35,860 main ERROR Unable to create file /opt/sonarqube/logs/es.log java.io.IOException: Permission denied
	at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
....
2024-03-13 04:28:35,868 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@ae3540e] unable to create manager for [/opt/sonarqube/logs/es.log]

.....




Running on : sonarqube:9.9.4-community

Fixed my problem by changing changing file permission.

chmod 777 data
chmod 777 extensions
chmod 777 logs
2 Likes

Mod 775 will also work.

1 Like