Cannot Download sonar-scanner in Docker Builds

I’m getting a timeout when downloading the sonar-scanner zip in Docker builds, I tried with both debian-based and alpine-based base image, but it will give an error in both cases.

Here’s my Dockerfile:

FROM golang:1.17

COPY . .

RUN . ./install_sonar_scanner.sh

Here’s my install_sonar_scanner.sh script:

apt-get update && apt-get install -y unzip wget
mkdir /downloads/sonarqube -p
cd /downloads/sonarqube
wget -O sonar-scanner-cli-4.2.0.1873-linux.zip http://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
unzip sonar-scanner-cli-4.2.0.1873-linux.zip
mv sonar-scanner-4.2.0.1873-linux /opt/sonar-scanner

The request takes a long time and then it timeouts, here’s the error:

Location: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip [following]
--2021-09-22 21:37:12--  https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|91.134.125.245|:443... connected.
HTTP request sent, awaiting response... Read error (Connection timed out) in headers.
Retrying.
--2021-09-22 21:52:13--  (try: 2)  https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|91.134.125.245|:443... connected.
HTTP request sent, awaiting response... Read error (Connection timed out) in headers.
Retrying.
--2021-09-22 22:07:15--  (try: 3)  https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|91.134.125.245|:443... connected.
HTTP request sent, awaiting response... Read error (Connection timed out) in headers.
Retrying.
--2021-09-22 22:22:19--  (try: 4)  https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|91.134.125.245|:443... connected.
HTTP request sent, awaiting response... 
ERROR: Job failed: execution took longer than 1h0m0s seconds

Due to this error, I am unable to create a Docker image with both Golang and sonar-scanner in it.

Looking forward for your support.

Thanks,
Dogac

Hi @dogac_akyildiz ,

this is working fine on my end. is there maybe a proxy blocking the download in your infrastructure? also 4.2.0.1873 is quiet outdated for the scanner-cli.

Hi @DefinitelyNotTobi

I can download it in my local machine and also in GitLab CI environment with no problem, this only happens in Docker builds.

This timeout happens with the latest zip too which is sonar-scanner-cli-4.6.2.2472-linux.zip.

Let me check about the proxy.

Thank you for your response,
Dogac