version: '3.7'
services:
#Create service sonarqube
sonarqube:
#Get lastest image from DockerHub
image: sonarqube:8-community
#set container name
container_name: sonarqube
ports:
- 9000:9000
#this service is assigned to network sonarnet
networks:
- sonarnet
#Set username, password and url to connect postgresql database
environment:
SONARQUBE_JDBC_USERNAME: sonar
SONARQUBE_JDBC_PASSWORD: sonar
SONARQUBE_JDBC_URL: jdbc:postgresql://db/sonar
#Set volumes which will sync data to real machine
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
#Create service postgres database
db:
#Get lastest image from DockerHub
image: postgres
#this service is assigned to network sonarnet
networks:
- sonarnet
#Set username and password for postgres database
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
#Set volumes which will sync data to real machine
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
#Create network sonarnet
networks:
sonarnet:
#Create volumes on real machine that data of container can sync
volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data: