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.

  • Can I Run a dotnet app which is hosted on IIS in a docker container?
  • Run one app on multiple elastic beanstalk instances
  • Can we run multi-process program in docker?
  • Docker Remote API & Binds
  • Cannot start Spark in Docker container
  • How do I pass the host's IP address to my container in Docker
  • 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

  • Rails console into Docker on Heroku
  • Exposing ports to all containers, not only the host
  • Docker: Build your own image issue
  • structure for ECR Repo
  • Connect docker container to database in host's local network
  • HTTPS URL Redirecting not working with HaProxy
  • 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.