I have SonarQube and Jenkins dockerized(They're running on different containers); sonar is running on localhost:9000 and Jenkins is running on localhost:8080. I configured the Sonar credentials(with acces Token) on Jenkins, but i when run SonarScanner I'm getting the following error by SonarScaner on Jenkins:
ERROR: SonarQube server [http://localhost:9000] can not be reached
INFO: ----------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ----------------------------------------------------------------
INFO: Total time: 0.358s
INFO: Final Memory: 4M/119M
INFO: ----------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to execute SonarQube
ERROR: Caused by: Fail to get bootstrap index from server
ERROR: Caused by: Failed to connect to localhost/127.0.0.1:9000
ERROR: Caused by: Connection refused (Connection refused)
How could i solve this, or make that both containers communicate between each others?
You can't use
127.0.0.1
as the IP address because that's the IP of the local container. You need to use the IP of the host.I wrote an article on how to setup a Docker container of Jenkins and SonarQube to talk to each other that explains the setup.