Starting SonarQube container

Start the SonarQube Server container either from the command line (docker run) or from a configuration file (docker compose).

Starting the container by using docker run

Run the image with your database properties defined using the -e environment variable flag:

$> docker run -d --name sonarqube \
    -p 9000:9000 \
    -e SONAR_JDBC_URL=... \
    -e SONAR_JDBC_USERNAME=... \
    -e SONAR_JDBC_PASSWORD=... \
    -v sonarqube_data:/opt/sonarqube/data \
    -v sonarqube_extensions:/opt/sonarqube/extensions \
    -v sonarqube_logs:/opt/sonarqube/logs \
    <image_name>

Note that:

  • By default, the server running within the container will listen on port 9000. The -p 9000:9000 argument is used to expose the container port 9000 to the host port 9000: -p port1:port2 maps container’s port port1 as port2 on the host.

  • For <image_name>, check the tags currently available on the DockerHub page.

Starting the container by using Docker compose

If you’re using Docker Compose, use this yml file example as a reference when configuring your .yml file.

Note that:

  • By default, the server running within the container will listen on port 9000. The following code is used to expose the container port 9000 to the host port 9000 ("port1:port2" maps container’s port port1 as port2 on the host):

ports:

      - "9000:9000"
  • In the image tag, use the tag value corresponding to the SonarQube Server version you want to use. Check the SonarQube Server image tags currently available on the DockerHub page. For example, to use the LTA version of the Developer Edition:

image:  sonarqube:2025-lta-developer

Unless you intend to delete the database and start new when running your image, be careful not to use -v to docker-compose down and, be careful when running commands like docker system prune or docker volume prune; regardless if you use an external: true parameter, your database volumes will not persist beyond the initial startup and shutdown of SonarQube.

Last updated

Was this helpful?