Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker starts sonarqube:7.5-community fails with es log permission

We are moving all things onto docker include Sonar.

Version

Docker version 1.13.1, build b2f74b2/1.13.1
SonarQube Image: sonarqube:7.5-community

Command

sudo docker run -d --name sonar --restart always --privileged=true -p 9000:9000 -p 9092:9092 
-v /home/test/sonardata/conf:/opt/sonarqube/conf  
-v /home/test/sonardata/data:/opt/sonarqube/data 
-v /home/test/sonardata/logs:/opt/sonarqube/logs 
-v /home/test/sonardata/extensions:/opt/sonarqube/extensions -e "SONARQUBE_JDBC_USERNAME=sonar"  -e "SONARQUBE_JDBC_PASSWORD=sonar" -e "SONARQUBE_JDBC_URL=jdbc:mysql://172.17.0.2:3306/db_sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false" sonarqube:7.5-community

Log

02:05:41.953 [main] WARN org.sonar.application.config.AppSettingsLoaderImpl - Configuration file not found: /opt/sonarqube/conf/sonar.properties
2019.05.07 02:05:42 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
2019.05.07 02:05:42 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.05.07 02:05:42 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch -Epath.conf=/opt/sonarqube/temp/conf/es
2019.05.07 02:05:43 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2019.05.07 02:05:44 INFO  app[][o.e.p.PluginsService] no modules loaded
2019.05.07 02:05:44 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2019-05-07 02:05:48,623 main ERROR Unable to create file /opt/sonarqube/logs/es.log java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:1012)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:628)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)
        at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
        at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:144)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:60)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
...

  searched a lot, seems most suggest to change the folder permission. My mapping folder use the 'test' users and it is an sudoer user not the root one. Further more, the docker command need the 'sudo' permission.

Here is a link for run-as issue: https://michalwegrzyn.wordpress.com/2016/07/14/do-not-run-sonar-as-root/

A lot of thanks if someone can help.

like image 200
Wei Yang Avatar asked Nov 07 '22 17:11

Wei Yang


1 Answers

This is because docker user doesn't have the permission to write to /opt/sonarqube/* directories; you can make sure to run container with appropriate access, or change /opt/sonarqube/* access permissions - e.g.

sudo chmod 777 /opt/sonarqube/*
like image 170
Suleiman Abualrob Avatar answered Nov 14 '22 21:11

Suleiman Abualrob