Sonarqube docker image based on Debian Jessie and Oracle JDK 8.
This Sonarqube docker image contains the following software components:
For data storage you will need a relational database. At the moment, these databases are supported:
These tcp ports are exposed:
- 9000 (Web frontend)
When you start the Sonarqube container, you can adjust the configuration by passing one or more environment variables on the docker run
command line:
- The database type to use
- Possible values:
mysql
,postgresql
- Default value:
mysql
- The database hostname or ip address as string
- Default value:
$MYSQL_PORT_3306_TCP_ADDR
orsonarqube-mysql
- The database port as a numeric value
- Default value:
$MYSQL_PORT_3306_TCP_PORT
or3306
- The database name as string
- Default value:
$MYSQL_ENV_MYSQL_DATABASE
orsonarqube
- The database user as string
- Default value:
$MYSQL_ENV_MYSQL_USER
orsonarqube
- The database password as string
- Default value:
$MYSQL_ENV_MYSQL_PASSWORD
ormy-password
- The webapp context path as string
- Default value:
- The java command line arguments for the sonarqube java process
- Default value:
-
Make sure that your mysql database server allows external access
-
Create a database with name
sonarqube
and allow usersonarqube
to access it -
Run the Sonarqube container with the following command:
docker run --name sonarqube-app -d -p 9000:9000 -e DB_HOST=192.168.0.1 -e DB_PASS=my-password -v /opt/docker/sonarqube/app/conf:/opt/sonarqube/conf -v /opt/docker/sonarqube/app/data:/opt/sonarqube/data -v /opt/docker/sonarqube/app/extensions:/opt/sonarqube/extensions chrisipa/sonarqube
- Run mysql container with this command:
docker run --name sonarqube-mysql -d -e MYSQL_ROOT_PASSWORD=my-root-password -e MYSQL_DATABASE=sonarqube -e MYSQL_USER=sonarqube -e MYSQL_PASSWORD=my-password -v /opt/docker/sonarqube/mysql:/var/lib/mysql mysql:latest
- Run Sonarqube container by linking to the newly created mysql container:
docker run --name sonarqube-app --link sonarqube-mysql:mysql -d -p 9000:9000 -v /opt/docker/sonarqube/app/conf:/opt/sonarqube/conf -v /opt/docker/sonarqube/app/data:/opt/sonarqube/data -v /opt/docker/sonarqube/app/extensions:/opt/sonarqube/extensions chrisipa/sonarqube
- Create docker compose file
docker-compose.yml
with your configuration data:
mysql:
image: mysql
volumes:
- /opt/docker/sonarqube/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=my-root-password
- MYSQL_DATABASE=sonarqube
- MYSQL_USER=sonarqube
- MYSQL_PASSWORD=my-password
sonarqube:
image: chrisipa/sonarqube
links:
- mysql:mysql
ports:
- 9000:9000
volumes:
- /opt/docker/sonarqube/app/conf:/opt/sonarqube/conf
- /opt/docker/sonarqube/app/data:/opt/sonarqube/data
- /opt/docker/sonarqube/app/extensions:/opt/sonarqube/extensions
- /opt/docker/sonarqube/app/logs:/opt/sonarqube/logs
environment:
- SONARQUBE_CONTEXT_PATH=/sonar
- Run docker containers with docker compose:
docker-compose up -d
See parent image: chrisipa/java