Problem in the configuration of the external database

Good afternoon, I just installed a sonarqube docker and a postgres docker, however, when I build the sonarqube docker it continues to use the embedded database and not my postgres database, please can you help me? the commands are the following:

docker run --name postgres-db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -p 5432:5432 -d postgres

docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 -e sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar -e sonar.jdbc.username=sonar -e sonar. jdbc.password=sonar sonarqube

Hi,

It should be:

docker run -d --name sonarqube -p 9000:9000 -e SONAR_JDBC_URL=jdbc:postgresql://postgres-db:5432/sonar -e SONAR_JDBC_USERNAME=sonar -e SONAR_JDBC_PASSWORD=sonar sonarqube

(reference)

I just deleted my dockers that I had but when I run your command line it activates my docker but then it shuts down and doesn’t let me run it

then my command line would look like this?

docker run --name postgres-db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -p 5432:5432 -d postgres

docker run -d --name sonarqube -p 9000:9000 -e SONAR_JDBC_URL=jdbc:postgresql://postgres-db:5432/sonar -e SONAR_JDBC_USERNAME=sonar -e SONAR_JDBC_PASSWORD=sonar sonarqube