- docker run -d --name sonarqube1 -p 9000:9000 sonarqube
- docker logs sonarqube1
- docker stop sonarqube1
- docker rm sonarqube1
- docker run -d --name sonarqube2 -p 80:9000 sonarqube
- docker exec -it sonarqube2 sh
- docker run -d --name mysql1 -e MYSQL_ROOT_PASSWORD=changeit mysql
- docker exec -it mysql1 sh
- mysql -u root -pchangeit
- create database sonardb;
- grant all on sonardb.* to sonaruser@'%' identified by 'sonarpass';
- flush privileges;
- exit
- exit
- docker inspect mysql1 | grep IPAddress
- docker run -d --name mysql2 --link mysql1 -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
- docker exec -it mysql2 sh
- mysql -h <mysql1_IPAddress> -u sonaruser -psonarpass
- show databases;
- exit
- exit
- docker run -d --name sonarqube3 -p 9000:9000 --link mysql1 -e SONARQUBE_JDBC_USERNAME=sonaruser -e SONARQUBE_JDBC_PASSWORD=sonarpass -e "SONARQUBE_JDBC_URL=jdbc:mysql://mysql1/sonardb?useUnicode=true&characterEncoding=utf8" sonarqube
搭配 PostgreSQL 似乎更容易些,且效率、評價都好,精簡至四道指令完成:
- docker run -d --name postgres1 postgres
- docker exec -it postgres1 createuser -U postgres -d -P -s sonar (input sonar / sonar)
- docker exec -it postgres1 createdb -U sonar sonar
- docker run -d --name sonarqube4 -p 9000:9000 --link postgres1 -e SONARQUBE_JDBC_URL=jdbc:postgresql://postgres1/sonar sonarqube