In here we will see how to containerize sonarqube in Docker.
Install docker
Install docker compose
To create the docker container for the postgres run the following command. Make sure that the given port in the following command is not used already
docker run --name postgres -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -it postgres
To see the created container run the following command,this command shows all the containers
docker ps -a
To create the docker container for the postgres run the following command. Make sure that the given port in the following command is not used already
docker run --name sonarqube --link postgres -e sonar.jdbc.url=jdbc:postgresql://postgres:5432/sonar -p 9000:9000 -it sonarqube
To see the created container run the following command,this command shows all the containers
docker ps -a
To run the SonarQube enter the following url in browser
http://localhost:9000/about
Click on the login
By default,
userName: admin and password: admin
After login if we need to change the password click on Administrator and then click in My Account
Then select the security
Then change the passwor by give the old password and new password
Login witht the changed password
This is the another way to containerize the sonarqube with postgres. Download the following file
https://github.com/udhaya-un/SonarQube/blob/master/docs/docker-compose.yml
Make sure that the port given in the file are not in use.
open the directory of this file in terminal and run the following command to up the containers
docker-compose up -d
When up the docker compose fiel at that time volume of the container is created, to see the volume execute the following command
docker exec -it [containername] bash
Now, open the folder Which is mentioned under volumes for postgres there you can able to see the folder *data which is the backup for container.
cd var/lib/postgresql
Do the same for the sonarqube also to see the volumes.
To run the SonarQube enter the following url in browser
http://localhost:9000/about