Create a SonarQube instance using Docker.
You will need to have Docker installed on your machine.
Jan 4, 2023
- Pull the latest version of the SonarQube image from Docker Hub:
docker pull sonarqube
- Run the SonarQube container, mapping the container’s internal port 9000 to an unused host port of your choice (e.g. 9000):
docker run -d — name sonarqube -p 9000:9000 sonarqube
- Wait a few minutes for the SonarQube instance to fully start up, and then visit http://localhost:9000 in a web browser to access the SonarQube web UI.
- If you want to persist data across restarts of the SonarQube container, you can add a volume mapping for the container’s /opt/sonarqube/data directory:
docker run -d — name sonarqube -p 9000:9000 -v /my/host/path:/opt/sonarqube/data sonarqube
This will store the SonarQube data on the host in the specified directory, so that it is not lost when the container is stopped or removed.