Install and Configure SonarQube with PostgeSQL in Docker
September 6, 2023 2023-09-09 8:35Install and Configure SonarQube with PostgeSQL in Docker
Install and Configure SonarQube with PostgeSQL in Docker
What is SonarQube?
SonarQube is an opensource tool that helps self-managed, automatic code review tool that systematically and deliver your code clean. This help you to perform continuous code inspections of your projects and can support 30+ different programming languages to give your code meet high-quality. Can easily integrates in your CI pipeline jobs.
What is PostgreSQL?
PostgreSQL is an open source and powerful object-relational database system, it a strong reputation for reliability,
feature robustness, and performance executes on all major operating system like, Linux, Unix, HP-UX, Mac, etc.
This posts can understand how to Install and Configure SonarQube with PostgreSQL in Docker. Just follow the steps below,
Install a Docker daemon in your Linux machine, if not installed just follow the instruction from the links below,
File name: docker-compose.yaml
version: "3"
services:
sonarqube:
image: sonarqube:8.2-community
depends_on:
- db
ports:
- "9000:9000"
networks:
- sonarqubenet
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonarqube
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_logs:/opt/sonarqube/logs
- sonarqube_temp:/opt/sonarqube/temp
restart: on-failure
container_name: sonarqube
db:
image: postgres:12-bullseye
networks:
- sonarqubenet
environment:
POSTGRES_DB: "sonarqube"
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
restart: on-failure
container_name: postgresql
networks:
sonarqubenet:
driver: bridge
volumes:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
sonarqube_temp:
postgresql:
postgresql_data:
Once saved the above yaml file in a docker-compose.yaml file then execute the command below,
docker-compose up -d
the outputs:
[+] Running 2/2
⠿ Container postgresql Started 21.3s
⠿ Container sonarqube Started 16.9s
list out the docker container which are running your machine,
docker container ps
If you would like to see the docker container logs for both Sonarqube and Postgres, use the command below,
docker container logs sonarqube
docker container logs postgresql
Open your browser and hit the URL on the box: http://localhost:9000/ you are able to see the SonarQube home page window, click on “Login” link and use the default login details username: admin and password: admin
Login page:
Report page: