# Starting SonarQube container

## Starting the container by using docker run <a href="#using-docker-run" id="using-docker-run"></a>

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

```sh
$> 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](https://hub.docker.com/_/sonarqube).

## Starting the container by using Docker compose <a href="#by-using-docker-compose" id="by-using-docker-compose"></a>

If you’re using [Docker Compose](https://docs.docker.com/compose/), use this [yml file example](https://github.com/SonarSource/docker-sonarqube/tree/master/example-compose-files/sq-with-postgres) 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):

```css-79elbk
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](https://hub.docker.com/_/sonarqube). For example, to use the LTA version of the Developer Edition:

```css-79elbk
image:  sonarqube:2025-lta-developer
```

{% hint style="info" %}
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.
{% endhint %}

## Related pages <a href="#related-pages" id="related-pages"></a>

* [Installation overview](/sonarqube-server/2025.3/server-installation/from-docker-image/installation-overview.md)
* [Basic installation](/sonarqube-server/2025.3/server-installation/from-docker-image/basic-installation.md)
* [Advanced setup](/sonarqube-server/2025.3/server-installation/from-docker-image/advanced-setup.md)
* **Configuring network security features:**
  * [Securing behind a proxy](/sonarqube-server/2025.3/server-installation/network-security/securing-behind-proxy.md)
  * [Network rules](/sonarqube-server/2025.3/server-installation/network-security/network-rules.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.3/server-installation/from-docker-image/starting-sonarqube-container.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
