I successfully started SonarQube using docker image, which points on Postgres DB. and then I tried with docker-compose up down many times, to make sure all data were saved, and everything went fine.
Then we apply for the license!
But, after a few days. we take docker-compose down, and up again data were lost, while it should be stored in a local volume. Note[other images in the same docker-compose file like Jenkins, doesn’t lose the data]
Can you please advise us ? what happened ? did we lose the data at all? how we can avoid this again ?
here is the docker-copose.yml:
version: "3"
services:
sonarqube:
image: sonarqube:lts-developer
restart: unless-stopped
depends_on:
- db
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
volumes:
- sonarqube_conf:/var/lib/docker/volumes/sonarqube_conf
- sonarqube_data:/var/lib/docker/volumes/sonarqube_data
- sonarqube_extensions:/var/lib/docker/volumes/sonarqube_extensions
- sonarqube_bundled-plugins:/var/lib/docker/volumes/bundled-plugins
ports:
- "9000:9000"
- "9092:9092"
db:
image: postgres:latest
restart: unless-stopped
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
POSTGRES_DB: sonar
volumes:
- postgresql:/var/lib/docker/volumes/postgresql_data
- postgresql_data:/var/lib/docker/volumes/postgresql_data/_data
jenkins:
image: jenkins:2.60.3
restart: unless-stopped
privileged: true
user: root
ports:
- 8083:8080
- 50003:50000
container_name: jenkins-ci-cd
volumes:
- jenkins_data:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
volumes:
postgresql_data:
sonarqube_bundled-plugins:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
sonarqube_conf:
jenkins_data:
postgresql: