SonarQube is an open source quality management platform, dedicated to continuously analyze and measure technical quality, from project portfolio to method.
$ curl -LO https://raw.githubusercontent.com/bitnami/bitnami-docker-sonarqube/master/docker-compose.yml
$ docker-compose up
- Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
- With Bitnami images the latest bug fixes and features are available as soon as possible.
- Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
- All our images are based on minideb a minimalist Debian based container image which gives you a small base container image and the familiarity of a leading linux distribution.
- All Bitnami images available in Docker Hub are signed with Docker Content Trust (DTC). You can use
DOCKER_CONTENT_TRUST=1
to verify the integrity of the images. - Bitnami container images are released daily with the latest distribution packages available.
This CVE scan report contains a security report with all open CVEs. To get the list of actionable security issues, find the "latest" tag, click the vulnerability report link under the corresponding "Security scan" field and then select the "Only show fixable" filter on the next page.
You can find an example for testing in the file test.yaml
. To launch this sample file run:
$ kubectl apply -f test.yaml
NOTE: If you are pulling from a private containers registry, replace the image name with the full URL to the docker image. E.g.
- image: 'your-registry/image-name:your-version'
NOTE: Debian 9 and Oracle Linux 7 images have been deprecated in favor of Debian 10 images. Bitnami will not longer publish new Docker images based on Debian 9 or Oracle Linux 7.
Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page.
8-debian-10
,8.2.0-debian-10-r9
,8
,8.2.0
(8/debian-10/Dockerfile)7-debian-10
,7.9.2-debian-10-r49
,7
,7.9.2
,latest
(7/debian-10/Dockerfile)
Subscribe to project updates by watching the bitnami/sonarqube GitHub repo.
To run this application you need Docker Engine >= 1.10.0
. Docker Compose is recommended with a version 1.6.0
or later.
Please also make sure your host machine meets the requirements of SonarQube itself, taking extra care about the platform notes section.
SonarQube requires access to a PostgreSQL database to store information. We'll use our very own PostgreSQL image for the database requirements.
The main folder of this repository contains a functional docker-compose.yml
file. Run the application using it as shown below:
$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-sonarqube/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d
If you want to run the application manually instead of using docker-compose
, these are the basic steps you need to run:
- Create a network
$ docker network create sonarqube-tier
- Create a volume for PostgreSQL persistence and create a PostgreSQL container
$ docker volume create --name postgresql_data
$ docker run -d --name postgresql \
-e ALLOW_EMPTY_PASSWORD=yes \
-e POSTGRESQL_USERNAME=bn_sonarqube \
-e POSTGRESQL_DATABASE=bitnami_sonarqube \
-e POSTGRESQL_PASSWORD=bitnami1234 \
--net sonarqube-tier \
--volume postgresql_data:/bitnami/postgresql \
bitnami/postgresql:latest
- Create volumes for SonarQube persistence and launch the container
$ docker volume create --name sonarqube_data
$ docker run -d --name sonarqube -p 80:9000 \
-e ALLOW_EMPTY_PASSWORD=yes \
-e SONARQUBE_DATABASE_USER=bn_sonarqube \
-e SONARQUBE_DATABASE_NAME=bitnami_sonarqube \
-e SONARQUBE_DATABASE_PASSWORD=bitnami1234 \
--net sonarqube-tier \
--volume sonarqube_data:/bitnami \
bitnami/sonarqube:latest
Access your application at http://your-ip:9000
If you remove the container all your data and configurations will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.
For persistence you should mount a volume at the /bitnami
path. Additionally you should mount a volume for persistence of the PostgreSQL data.
The above examples define docker volumes namely postgresql_data
and sonarqube_data
. The Sonarqube application state will persist as long as these volumes are not removed.
To avoid inadvertent removal of these volumes you can mount host directories as data volumes. Alternatively you can make use of volume plugins to host the volume data.
The following docker-compose.yml
template demonstrates the use of host directories as data volumes.
version: '2'
services:
postgresql:
image: 'bitnami/postgresql:latest'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- POSTGRESQL_USER=bn_sonarqube
- POSTGRESQL_DATABASE=bitnami_sonarqube
- POSTGRESQL_PASSWORD=bitnami1234
volumes:
- /path/to/postgresql-persistence:/bitnami
sonarqube:
image: bitnami/sonarqube:latest
depends_on:
- postgresql
ports:
- '80:9000'
environment:
- SONARQUBE_DATABASE_USER=bn_sonarqube
- SONARQUBE_DATABASE_NAME=bitnami_sonarqube
- SONARQUBE_DATABASE_PASSWORD=bitnami1234
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- /path/to/sonarqube-persistence:/bitnami
- Create a network (if it does not exist)
$ docker network create sonarqube-tier
- Create a PostgreSQL container with host volume
$ docker run -d --name postgresql \
-e ALLOW_EMPTY_PASSWORD=yes \
-e POSTGRESQL_USERNAME=bn_sonarqube \
-e POSTGRESQL_DATABASE=bitnami_sonarqube \
-e POSTGRESQL_PASSWORD=bitnami1234 \
--net sonarqube-tier \
--volume /path/to/postgresql-persistence:/bitnami \
bitnami/postgresql:latest
- Create the SonarQube the container with host volumes
$ docker run -d --name sonarqube -p 80:9000 \
-e ALLOW_EMPTY_PASSWORD=yes \
-e SONARQUBE_DATABASE_USER=bn_sonarqube \
-e SONARQUBE_DATABASE_NAME=bitnami_sonarqube \
-e SONARQUBE_DATABASE_PASSWORD=bitnami1234 \
--net sonarqube-tier \
--volume /path/to/sonarqube-persistence:/bitnami \
bitnami/sonarqube:latest
Bitnami provides up-to-date versions of PostgreSQL and SonarQube, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container. We will cover here the upgrade of the SonarQube container. For the PostgreSQL upgrade see https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md#upgrade-this-image
The bitnami/sonarqube:latest
tag always points to the most recent release. To get the most recent release you can simple repull the latest
tag from the Docker Hub with docker pull bitnami/sonarqube:latest
. However it is recommended to use tagged versions.
- Get the updated images:
$ docker pull bitnami/sonarqube:latest
- Stop your container
- For docker-compose:
$ docker-compose stop sonarqube
- For manual execution:
$ docker stop sonarqube
- Take a snapshot of the application state
$ rsync -a /path/to/sonarqube-persistence /path/to/sonarqube-persistence.bkp.$(date +%Y%m%d-%H.%M.%S)
Additionally, snapshot the PostgreSQL data
You can use these snapshots to restore the application state should the upgrade fail.
- Remove the stopped container
- For docker-compose:
$ docker-compose rm sonarqube
- For manual execution:
$ docker rm sonarqube
- Run the new image
- For docker-compose:
$ docker-compose up sonarqube
- For manual execution (mount the directories if needed):
docker run --name sonarqube bitnami/sonarqube:latest
The SonarQube instance can be customized by specifying environment variables on the first run. The following environment values are provided to custom SonarQube:
SONARQUBE_USERNAME
: SonarQube application username. Default: adminSONARQUBE_PASSWORD
: SonarQube application password. Default: bitnamiSONARQUBE_PORT_NUMBER
: SonarQube Web application port. Default: 9000SONARQUBE_ELASTICSEARCH_PORT_NUMBER
: SonarQube Elasticsearch application port. Default: 9001SONARQUBE_ENABLE_DEMO_DATA
: It can be used to import a sample project and install a sample plugin. Default: noSONARQUBE_WEB_CONTEXT
: SonarQube prefix used to access to the application. Default: /SONARQUBE_CE_JAVA_ADD_OPTS
: Additional Java options for Compute Engine. No defaults.SONARQUBE_ELASTICSEARCH_JAVA_ADD_OPTS
: Additional Java options for Elasticsearch. No defaults.SONARQUBE_WEB_JAVA_ADD_OPTS
: Additional Java options for Web. No defaults.SONARQUBE_START_TIMEOUT
: Timeout for the application to start in seconds. Default: 300.
POSTGRESQL_HOST
: Hostname for PostgreSQL server. Default: postgresqlPOSTGRESQL_PORT_NUMBER
: Port used by PostgreSQL server. Default: 5432SONARQUBE_DATABASE_NAME
: Database name that SonarQube will use to connect with the database. Default: bitnami_sonarqubeSONARQUBE_DATABASE_USER
: Database user that SonarQube will use to connect with the database. Default: bn_sonarqubeSONARQUBE_DATABASE_PASSWORD
: Database password that SonarQube will use to connect with the database. No defaults.ALLOW_EMPTY_PASSWORD
: It can be used to allow blank passwords. Default: no
POSTGRESQL_HOST
: Hostname for PostgreSQL server. Default: postgresqlPOSTGRESQL_PORT_NUMBER
: Port used by PostgreSQL server. Default: 5432POSTGRESQL_ROOT_USER
: Database admin user. Default: rootPOSTGRESQL_ROOT_PASSWORD
: Database password for thePOSTGRESQL_ROOT_USER
user. No defaults.POSTGRESQL_CLIENT_CREATE_DATABASE_NAME
: New database to be created by the postgresql client module. No defaults.POSTGRESQL_CLIENT_CREATE_DATABASE_USERNAME
: New database user to be created by the postgresql client module. No defaults.POSTGRESQL_CLIENT_CREATE_DATABASE_PASSWORD
: Database password for thePOSTGRESQL_CLIENT_CREATE_DATABASE_USERNAME
user. No defaults.ALLOW_EMPTY_PASSWORD
: It can be used to allow blank passwords. Default: no
This requires a minor change to the docker-compose.yml
file present in this repository:
services:
postgresql:
...
environment:
- POSTGRESQL_USER=bn_sonarqube
- POSTGRESQL_DATABASE=bitnami_sonarqube
- POSTGRESQL_PASSWORD=bitnami1234
- ALLOW_EMPTY_PASSWORD=yes
...
sonarqube:
...
environment:
- POSTGRESQL_HOST=postgresql
- POSTGRESQL_PORT_NUMBER=5432
- SONARQUBE_DATABASE_USER=bn_sonarqube
- SONARQUBE_DATABASE_NAME=bitnami_sonarqube
- SONARQUBE_DATABASE_PASSWORD=bitnami1234
- ALLOW_EMPTY_PASSWORD=yes
...
$ docker run -d --name sonarqube -p 80:9000 \
--net sonarqube-tier \
-e ALLOW_EMPTY_PASSWORD=yes \
-e SONARQUBE_DATABASE_USER=bn_sonarqube \
-e SONARQUBE_DATABASE_NAME=bitnami_sonarqube \
-e SONARQUBE_PASSWORD=my_password \
--volume sonarqube_data:/bitnami \
bitnami/sonarqube:latest
To configure SonarQube to send email using SMTP you can set the following environment variables:
SMTP_HOST
: Host for outgoing SMTP email. No defaults.SMTP_PORT
: Port for outgoing SMTP email. No defaults.SMTP_USER
: User of SMTP used for authentication (likely email). No defaults.SMTP_PASSWORD
: Password for SMTP. No defaults.SMTP_PROTOCOL
: Secure connection protocol to use for SMTP [tls, ssl, none]. No defaults.
This would be an example of SMTP configuration using a GMail account:
- Modify the
docker-compose.yml
file present in this repository:
sonarqube:
...
environment:
- POSTGRESQL_HOST=postgresql
- POSTGRESQL_PORT_NUMBER=5432
- SONARQUBE_DATABASE_USER=bn_sonarqube
- SONARQUBE_DATABASE_NAME=bitnami_sonarqube
- SONARQUBE_DATABASE_PASSWORD=bitnami1234
- SMTP_HOST=smtp.gmail.com
- SMTP_PORT=587
- SMTP_USER=your_email@gmail.com
- SMTP_PASSWORD=your_password
- SMTP_PROTOCOL=tls
...
- For manual execution:
$ docker run -d --name sonarqube -p 80:9000 \
--net sonarqube-tier \
--env SMTP_HOST=smtp.gmail.com --env SMTP_PORT=587 \
--env SMTP_USER=your_email@gmail.com --env SMTP_PASSWORD=your_password \
--env ALLOW_EMPTY_PASSWORD=yes --env SONARQUBE_DATABASE_USER=bn_sonarqube \
--env SONARQUBE_DATABASE_NAME=bitnami_sonarqube \
--volume sonarqube_data:/bitnami/sonarqube \
bitnami/sonarqube:latest
The Bitnami SonarQube container supports connecting the SonarQube application to an external database. In order to configure it, you should set the following environment variables:
POSTGRESQL_HOST
: Hostname for PostgreSQL server. Default: postgresqlPOSTGRESQL_PORT_NUMBER
: Port used by PostgreSQL server. Default: 5432SONARQUBE_DATABASE_NAME
: Database name that SonarQube will use to connect with the database. Default: bitnami_sonarqubeSONARQUBE_DATABASE_USER
: Database user that SonarQube will use to connect with the database. Default: bn_sonarqubeSONARQUBE_DATABASE_PASSWORD
: Database password that SonarQube will use to connect with the database. No defaults.
This would be an example of using an external database for SonarQube.
- Modify the
docker-compose.yml
file present in this repository:
sonarqube:
...
environment:
- POSTGRESQL_HOST=postgresql_host
- POSTGRESQL_ROOT_USER=postgresql_root_user
- POSTGRESQL_ROOT_PASSWORD=postgresql_root_password
- POSTGRESQL_PORT_NUMBER=5432
- SONARQUBE_DATABASE_NAME=sonarqube_db
- SONARQUBE_DATABASE_USER=sonarqube_user
- SONARQUBE_DATABASE_PASSWORD=sonarqube_password
...
- For manual execution:
$ docker run -d --name sonarqube -p 80:9000 \
--net sonarqube-tier \
--env POSTGRESQL_HOST=postgresql_host \
--env POSTGRESQL_PORT_NUMBER=5432 \
--env POSTGRESQL_ROOT_USER=postgresql_root_user \
--env POSTGRESQL_ROOT_PASSWORD=postgresql_root_password \
--env SONARQUBE_DATABASE_NAME=sonarqube_db \
--env SONARQUBE_DATABASE_USER=sonarqube_user \
--env SONARQUBE_DATABASE_PASSWORD=sonarqube_password \
--volume sonarqube_data:/bitnami \
bitnami/sonarqube:latest
We'd love for you to contribute to this container. You can request new features by creating an issue, or submit a pull request with your contribution.
If you encountered a problem running this container, you can file an issue. For us to provide better support, be sure to include the following information in your issue:
- Host OS and version
- Docker version (
$ docker version
) - Output of
$ docker info
- Version of this container (
$ echo $BITNAMI_IMAGE_VERSION
inside the container) - The command you used to run the container, and any relevant output you saw (masking any sensitive information)
Copyright 2015-2020 Bitnami
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.