SonarQube 10.3 server is not starting when run through docker on Amazon Linux 2

We’ve installed sonarQube 10.3 using docker command below docker run -d --name sonarqube \ -p 9000:9000 \ -e SONAR_JDBC_URL=... \ -e SONAR_JDBC_USERNAME=... \ -e SONAR_JDBC_PASSWORD=... \ -v sonarqube_data:/opt/sonarqube/data \ -v sonarqube_extensions:/opt/sonarqube/extensions \ -v sonarqube_logs:/opt/sonarqube/logs \ <image_name>

We see the below error.

ava.lang.IllegalStateException: Unable to access '' (/opt/sonarqube/data/es8)
        at org.elasticsearch.bootstrap.FilePermissionUtils.addDirectoryPath( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.Security.addFilePermissions( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.Security.createPermissions( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.Security.configure( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.Elasticsearch.initPhase2( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.Elasticsearch.main( ~[elasticsearch-8.11.0.jar:?]
Caused by: java.nio.file.AccessDeniedException: /opt/sonarqube/data/es8
        at sun.nio.fs.UnixException.translateToIOException(Unknown Source) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source) ~[?:?]
        at java.nio.file.Files.createDirectory(Unknown Source) ~[?:?]
        at java.nio.file.Files.createAndCheckIsDirectory(Unknown Source) ~[?:?]
        at java.nio.file.Files.createDirectories(Unknown Source) ~[?:?]
        at org.elasticsearch.bootstrap.Security.ensureDirectoryExists( ~[elasticsearch-8.11.0.jar:?]
        at org.elasticsearch.bootstrap.FilePermissionUtils.addDirectoryPath( ~[elasticsearch-8.11.0.jar:?]
        ... 5 more
ERROR: Elasticsearch did not exit normally - check the logs at /opt/sonarqube/logs/sonarqube.log

ERROR: Elasticsearch exited unexpectedly, with exit code 1
2024.01.09 21:09:51 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 1
2024.01.09 21:09:51 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.01.09 21:09:51 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
21:09:52.390 [main] WARN org.sonar.application.config.AppSettingsLoaderImpl -- Configuration file not found: /opt/sonarqube/conf/

Update: we are able to setup without any data attached to the docker ( without the -v). But when we add the data mounted and run the sonar with docker, we get this issue again. We need to have docker run with -v option to persist the data.
Any Advice on what is causing the access denied on this folder /opt/sonarqube/data/es8


Welcome to the community!

I’m going to preface my dumb question with the fact that I don’t have much Docker experience… But does the relevant user have perms to /opt/sonarqube/data?