docker run --name sonarqube -e SONARQUBE_JDBC_URL="jdbc:mysql://172.17.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false" -e SONARQUBE_JDBC_USERNAME=root -e SONARQUBE_JDBC_PASSWORD=123456 -p 9000:9000 -d sonarqube:7.4-community
#SONARQUBE_JDBC_URL数据库连接地址:使用ifconfig 查看docker0的inet ip
#这里用的是宿主机的数据库,不能直接用宿主机的ip,当然也可以使用部署的容器数据库,查看详情请搜索 --link db
#SONARQUBE_JDBC_USERNAME 用户名
#SONARQUBE_JDBC_PASSWORD 密码
启动虽然成功了,但因为sonnarqube不是在本机启动,需要在sonar-scanner/conf
目录更改文件sonar-scanner.properties
#sonar访问入口
sonar.host.url=http://192.168.10.134:9000
#数据库
sonar.jdbc.url=jdbc:mysql://192.168.10.134:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=root
sonar.jdbc.password=123456
其他配置文件不动,具体,若启动失败,可以参看我的另一篇博客windows安装sonarqube7.4+sonar-scanner-cli【JDK8+MySQL】