SonarQube server can not be reached by Jenkins using Docker

I have added a SonarQube Scanner analysis step to my Jenkins build, but the step fails:

[Test_gitlab] $ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/http_INTERNAL_DOCKER_IP_ADDRESS_9000/bin/sonar-scanner -e ******** -Dsonar.projectBaseDir=/var/jenkins_home/workspace/Test_gitlab
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/http_INTERNAL_DOCKER_IP_ADDRESS_9000/conf/
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_102 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-327.10.1.el7.x86_64 amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
ERROR: SonarQube server [SERVER_IP_ADDRESS:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.214s
INFO: Final Memory: 4M/209M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$
    at Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(
    at org.sonarsource.scanner.api.EmbeddedScanner.start(
    at org.sonarsource.scanner.cli.Main.execute(
    at org.sonarsource.scanner.cli.Main.main(
Caused by: java.lang.IllegalStateException: Fail to download libraries from server
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$
    ... 8 more
Caused by: java.lang.IllegalArgumentException: unexpected url: SERVER_IP_ADDRESS:9000/batch_bootstrap/index
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Request$Builder.url(
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(
    ... 11 more
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

My SonarQube Scanner is declared in Jenkins Global Tool Configuration. The name used is “http://SERVER_IP_ADDRESS:9000”. This is the same address as the server base URL that I have set within SonarQube General Settings.

  • Connect Docker Containers with remote debugger
  • MySQL in Docker container
  • cannot connect on SQLserver with Docker on mac
  • What is the cost of a container?
  • Using Docker and haproxy in order to load balance requests to multiple instances of embedded tomcat
  • docker on upstart on scaleway
  • I’m using Docker: Jenkins is in a Docker container, and so does SonarQube.

    The “unexpected url” mentioned in the stacktrace SERVER_IP_ADDRESS:9000/batch_bootstrap/index can be opened in a browser,
    which displays sonar-scanner-engine-shaded-6.1.jar|SOME_LETTERS_AND_NUMBERS.
    So why can’t Jenkins reach the server?

    I’ve also tried with Docker internal IP address, that can be found with:

    docker inspect SONARQUBE_CONTAINER_ID | grep IP

  • Using Gitlab CD and Docker
  • Redis Docker connection refused
  • How to configure `ng serve` to catch changes in a dockersized Angular 2 app?
  • Using UnixSignal in Mono throws System.ArgumentException
  • docker - build fails when COPYing file to root
  • Restrict system calls inside docker container
  • One Solution collect form web for “SonarQube server can not be reached by Jenkins using Docker”

    Find place where you define the “unexpected url” mentioned in the stacktrace (parameter of SonarQube Scanner) and prefix it with http://.

    URLs must start with a scheme – see Wikipedia. Browser simply adds http:// by default.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.