Closed afaucogney closed 8 years ago
@afaucogney How and where you start PostgreSQL? Note that recipe is about docker-compose
, where db
is name of a linked container which has PostgreSQL. Also note that in Kitematic with boot2docker localhost
refers to VM with Docker.
@Godin I'm not so advance in Docker stuff. So I just follow the doc, and expect (from what I understood) that a Postgresql db was on the container. That I just need to change envVar to link Sonar to PostGre ! Did I miss understood ?
https://hub.docker.com/_/sonarqube/
Database configuration By default, the image will use an embedded H2 database that is not suited for production.
The production database is configured with these variables: SONARQUBE_JDBC_USERNAME, SONARQUBE_JDBC_PASSWORD and SONARQUBE_JDBC_URL.
$ docker run -d --name sonarqube \ -p 9000:9000 -p 9092:9092 \ -e SONARQUBE_JDBC_USERNAME=sonar \ -e SONARQUBE_JDBC_PASSWORD=sonar \ -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost/sonar \ sonarqube More recipes can be found here.
@afaucogney yes, you misunderstood - PostgreSQL is not part of SonarQube image, otherwise it would violate principle of "separation" of containers. Cited example will work, if PostgreSQL is available on localhost
, e.g. by starting container with PostgreSQL (or non-container) in addition to container with SonarQube.
And indeed - documentation can be improved to make this obvious. It was written with assumption that reader already has a basic knowledges about containers.
Ok, yes it is confusion, especialy because of the command docker run ... sonarqube.....jdbc:postgresql://localhost/sonar
I realy feel that the db is on the container.
So if I well understood, I have to run a side Postgreslq container, that will work with the sonarqube container
@afaucogney yes
ok @Godin, this is what I did, and I progressed but still failed !
here is the config from SonarQube:
here is the config for PostGreSql
here is the log fro Sonar
her is the log for Postgresql
@afaucogney I don't see failure on screenshot of SQ startup.
Command line equivalent of usage of https://docs.docker.com/compose/ with https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md :
docker run --name db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -it postgres
docker run --name sq --link db -e SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonar -p 9000:9000 -it sonarqube
Sorry for being incompetent, but please do not make any assumption I will do something that is evident for you.
1/ In the first configuration I put in this thread with 4 screenshots, the SQ SONARQUBE_JDBC_URL envVar is jdbc:postgresql://192.168.99.100:32100/sonar : is that correct. This is the IP + port that is available in the other container (MAC IP PORT).
2/ I try to run you CLI command, it create 2 containers. Without any extra configuration, it fails to run. Do I need to do something else, or it is intended to be the turnkey procedure ?
@afaucogney once again - what means
it fails to run
? command not found, you can't open web interface, exception in log such as "connection refused" or some other, containers unexpectedly stop, something else ?
I'm asking because first message in this thread was about the case, when PostgreSQL wasn't started by you. And I don't see any evidence of "failure" afterwards - the last shown screenshot of SQ log looks absolutely clean (there is no exception, no errors, connection to DB looks successful). So please explain.
Docker is tricky on Macs (for now).
I ran the Docker-Compose script successfully on my mac, using docker-machine (not Kitematic). I had two suggestions. One, on the Mac the "address" of the SonarQube install is not "localhost" but rather the IP of the virtual machine. For docker-machine this means running docker-machine env <machine_name>
- for my case, I access SonarQube by going to http://192.168.99.100:9000 (not localhost, which I think is where it lives on Linux). Not sure how you determine this with kitematic but your console output suggests the SonarQube JDBC url is also the same as mine, so try that with port 9000?
The other thing I had to do in my compose approach was to change permissions on the "run.sh" script in the Sonarqube image directory. For some reason it wasn't allowing the sonar user to execute it.
@neilernst thank you for the assistance here.
Not sure that attempt to put all this information into documentation worth an efforts, this will also require maintenance afterwards. There are too many possible ways to use containers - on Linux, not on Linux, thru docker-machine, thru docker-compose, directly or thru kitematic, remotely, whatever else - you can name it, and new ways are coming. But PRs for https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md and https://github.com/docker-library/docs/tree/master/sonarqube are welcomed.
Permissions for file "run.sh" - do you remember what was the error and which changes you did?
Don't recall the specific error - I think in Docker Compose the logs mentioned "could not execute entry script" or something, so I did chmod 755 run.sh
, and it worked. There was some mention of this in the Docker documentation.
I agree this is too much for the wiki but I appreciate the compose script. I'll try to send PRs if I find something others could use.
Closing this ticket - no responses from author.
@afaucogney actually you need to docker exec
into the postgres container and create a database named sonar
. But make sure you have already mapped the postgres
volumes otherwise the database will be gone when the container exit.
docker exec -it [postgres_container_id] /bin/bash
createdb -U [postgres_user] sonar
I got the image in Doker-Hub and ran it with Kitematic.
After it started, I updated the required plugins.
Then I wanted to use the Postgresql db provided, by changing the envVar available in Kitematic as the following:
I also try with jdbc:postgresql://db:5432/sonar from the documentation linked recipe https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md
And the log is the following: