How to run SonarQube with docker-compose?

How to run SonarQube with docker-compose?

The value of high-quality code to the accomplishment of your project cannot be overstated. You can invest a ton of effort and money into your CI/CD pipeline and agile approach, but if your code doesn’t work best or has flaws, unfortunately, your product won’t succeed. To enable programmers in creating better, safer, and more reliable code, SonarQube will be used.

This blog will demonstrate how simple it is to incorporate SonarQube into your development process. A SonarQube server will be configured using Docker, and a tiny Java project will be subject to examination.

Ler’s understand 

What is SonarQube?

SonarQube is a code review tool for locating errors, odors in code, and flaws. Despite being an open-source platform, SonarSource also offers Enterprise and Data Center licenses with more sophisticated functionality.

Programming languages like Java, C#, and C/C++ are available through SonarQube. JavaScript, TypeScript, COBOL, Apex, PHP, Kotlin, Ruby, Scala, HTML, CSS, ABAP, Flex, Objective-C, Python, Go, Swift, PL/SQL, TQLQTL, VB.NET, VB6, and XML are some examples of supported programming languages. However, certain applications demand a business license.

To use SonarQube, there is no need to change your existing workflow or pick up new skills. It works with the most popular build tools, including Gradle, Ant, Maven, Make, MSBuild, and Maven. To evaluate your build as part of your regular build process, you only need to install the necessary plugin.

What is Docker Compose?

A tool called Docker compose was created to specify and distribute multi-container applications. You can define services in a YAML file using the docker-compose command. This command can either improve or ruin your entire construct

How to configure SonarQube with Docker-compose?

  1. Create SonarQube first using the Docker-compose.yml file.

Build docker-compose.yml

The configurations for installing SonarQube and Postgresql will all be defined in this file. Start the VIM editor, and then enter the following command to add the code:

sudo vi docker-compose.yml

Installing Docker compose is now complete: Using the docker-compose installation command

sudo apt-get install docker-compose –y

  1. Include current user in the Docker group:

sudo usermod -aG Docker $USER

  1. Generate a New directory 

mkdir ~/sonar

cd sonal/

  1. To set up SonarQube with PostgreSQL, let’s first generate a yaml file.

sudo nano docker-compose.yml

version: “3”



image: SonarQube:community


 – db


     SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar

     SONAR_JDBC_USERNAME: sonartest

    SONAR_JDBC_PASSWORD: sonartest


    – SonarQube_data:/opt/SonarQube/data

    – SonarQube_extensions:/opt/SonarQube/extensions

    – SonarQube_logs:/opt/SonarQube/logs


– “9000:9000”


 image: postgres:12


  POSTGRES_USER: sonartest



    – postgresql:/var/lib/postgresql

   – postgresql_data:/var/lib/postgresql/data







The SonarQube section containing the version is the most recent version. The Environment section specifies the variables that will be used to connect to the Postgresql database. The volume portion of SonarQube was utilized to save the configuration.

Following that, postgresql uses the most recent version, and the environment section is used to save the SonarQube database- JDBC connection.

5. Run the Docker compose command to execute the compose file:

sudo docker-compose up –d

6. List the currently active containers.

Using the docker ps command, you can see which containers are currently operating.

7. Check the docker compose logs command

docker-compose logs

8. Log in using the default credentials admin:admin.

How to find the best DevOps service provider for running Sonarqube with docker compose?

DevOps as a service allows your engineers to focus on what matters most: your product, rather than the infrastructure.

Implementing the DevOps process remains a hurdle for many businesses across the world wanting to use corporate DevOps to provide software and crucial upgrades to their customers. You must select a top-tier supplier with proven CI/CD methodologies and a high level of automation, allowing you to focus entirely on establishing and growing your product.

In today’s fast-paced IT industry, many firms and organizations provide DevOps as a service. So, how can you tell which ones are good for you and which aren’t? Is it simply a matter of technical skill and familiarity with DevOps best practices? It combines technological abilities, DevOps competence, and fundamental consulting capabilities. Here are a few things to think about when looking for a DevOps service provider.

Must be Empathetic

When meeting with a potential provider for the first time, be sure they are paying active attention to what you have to say. They need to get the problem statement.

A professional DevOps service will solicit your feedback on whether or not they have correctly identified all of the issues. In this case, empathy is an important word. They must be able to imagine themselves in your shoes. If they were the client, they would want their service provider to go through the issue again before discussing DevOps metrics.

Many DevOps service providers, especially the more experienced ones such as DxMinds, will behave intuitively. They have been there and will be glad to suggest potential solutions and DevOps KPIs monitor in order to meet the objectives

As a result, if the potential service provider interjects his opinion about release and deployment management or any other issue while you are describing the problem, this should act as an early warning sign.

Have an Open Mind

Because of the close association between DevOps and Agile, DevOps is also referred to as “Agile Delivery.” As a result, many individuals feel that DevOps implementation is something that only Agile teams can do.

While most experts agree that DevOps may be properly utilized inside Agile teams, your firm may be using the Waterfall model for genuine reasons. If this is the case, DevOps consultants must be able to give solutions that can be implemented right away to provide quick wins. For example, this could imply reducing the build and deployment time from many hours to minutes. The DevOps support service provider may regard such a target as weak, but it could ease a lot of strain on your team and allow them the time they need to look for new places to optimize. If you realize that you are reflecting certain key Agile practices throughout the process of such enhancements, you might consider making this change.

Own the High end experience 

You should hire a DevOps service provider who has at least five years of experience with automation technologies like Puppet, Ansible, Chef, and SaltStack, as well as a strong understanding of Python, Ruby, PHP, and Java. Furthermore, they should be familiar with continuous integration technologies such as Jenkins, CruiseControl, and CruiseControl.NET, to name a few. It will also be beneficial if they have experience with delivering code, database management, system design, and software architecture.

When interviewing candidates, inquire whether they have credentials in project management, risk management, or Scrum Master, or if they have knowledge in these areas. It makes no difference where the DevOps support service provider is located because the one who best matches your needs may not be in the area.

The DevOps expert will need to travel to your site location to observe and assess processes before making recommendations on how to solve them. Traveling from point A to point B in a fair period and without exceeding your budget is doable in today’s society.

Promote the best Environment

The human element gets overlooked because there is so much information about Agile and its methodology available. No matter what strategies are used, problems will still develop if team members do not get along. The DevOps service provider must be able to put together a team that is aware of one another’s needs and willing to help them.

To build such a team, the service provider must give the necessary leadership.

They should occasionally organize a team lunch, encourage daily stand-up meetings, and interact with the team to solve issues. Given that a team is not a group of indifferent, emotionless people, you do not need one.


In this post, you learned how to create a SonarQube server and incorporate static analysis into a Java build.

SonarQube is a sophisticated tool that will assist you in developing better code. You’ve already seen how simple it is to include it in your current process. When experimenting with existing code, it is recommended that you rely on an experienced DevOps service provider. Contact our development professionals for more personalized technical guidance to help you through the development process.

Send Message
We are here
How Can We help you?