Help with Docker Compose upgrade to 9.9LTS

On an Ubuntu 18.04LTS host with docker-compose v1.23.1:

I’m trying to upgrade from 9.3.0 Developer to 9.9 Developer. I’m currently running with Postgres v10, so I need to upgrade to at least v11.

So on a staging server I modified the docker-compose file to reflect the two new image versions (SQ 9.9-Dev and PG11.7), but only started the database service. I created an empty “sonar” db, and restored on it the backup from the running instance. I then started SQ as well. It ignored my database, and started H2 instead.

As a PoC I started a community edition SQ, this time it saw my restored database, and with /setup in the URL I successfully migrated/upgrade it. And yet, after all that, the GUI comes up with zero projects or users, everything has been wiped out.

I’ve spent 2 days already on this, it’s getting frustrating.

Please suggest a working upgrade path for me (I can’t find one in the upgrade guide), or a working docker-compose.yml file, whichever is easier for you.

Here is my initial (and working) docker-compose.yml file from the runnign 9.3.0 server.

version: "3"

services:
  sonarqube:
    container_name: sonar
    image: sonarqube:9.3.0-developer
    depends_on:
      - db
    restart: always
    ports:
      - "80:9000"
      - "9092:9092"
    networks:
      - sonarnet
    environment:
      - SONARQUBE_JDBC_USERNAME=sqube
      - SONARQUBE_JDBC_PASSWORD=something
      - SONARQUBE_JDBC_URL=jdbc:postgresql://sonar_db:5432/sonar
      - SONARQUBE_URL=https://sonarqube.mycompany.com
    security_opt:
      - "seccomp=/sonar/data/docker/seccomp-profile.json"
    volumes:
      - /sonar/data/sonarqube/sonarqube_data:/opt/sonarqube/data
      - /sonar/data/sonarqube/sonarqube_extensions:/opt/sonarqube/extensions
      - /sonar/data/sonarqube/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
  db:
    container_name: sonar_db
    image: postgres:10.10
    restart: always
    ports:
      - "5432:5432"
    networks:
      - sonarnet
    environment:
      - POSTGRES_USER=sqube
      - POSTGRES_PASSWORD=something
      - POSTGRES_DB=sonar
    volumes:
      - /sonar/data/sonarqube/postgresql:/var/lib/postgresql
      - /sonar/data/sonarqube/postgresql_data:/var/lib/postgresql/data
      - /sonar/backup:/tmp/backup
networks:
  sonarnet:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 10.40.1.1/24

Hey there.

As noted in the upgrade notes

Release 9.9 upgrade notes

  • The deprecated SONARQUBE_JDBC_USERNAME, SONARQUBE_JDBC_PASSWORD, and SONARQUBE_JDBC_URL variables have been removed. See Environment variables for up-to-date configuration variables.

It looks like you’re using those old configuration variables in your docker compose file, which are no longer supported. As such, you aren’t getting hooked up to your database.

Hi Guys,

Did you get how to solve this issue?

I tried to upgrade my docker-compose from 9-8-Community to 9-9Community following the steps in documentation:

But after execute migration database script, all projects and users is empty.
When I check in database(postgres), the data is there.

I’ll test some different Environment variables, but for know i’m a little lost.

Someone can help me, please? Thank’s

Hi guys,

I got to solve my issue and came here just to share about my solution…
The environment variables changes in 9.9 version how Colin said above and because this change, Sonarqube create a new empty database.
I just change this:

sonar.jdbc.username=
sonar.jdbc.username=
sonar.jdbc.username=

To:

SONAR_JDBC_USERNAME=
SONAR_JDBC_PASSWORD=
SONAR_JDBC_URL=

And worked well.
This was the main reason for me, and a plus one was because my postgres container was running in different docker network. After add –network=mysonarnet sonar get up well.