ADD command in Dockerfile download goes wrong

305 views Asked by At

I am downloading a jar file in my dockerfile with the command :

ADD https://sourceforge.net/projects/plantuml/files/${PLANTUML_VERSION}/plantuml.${PLANTUML_VERSION}.jar/download /usr/local/plantuml/plantuml.jar

PLANTUML_VERSION being declared as the environment variable "1.2020.16".

One times out of five, this command is downloading the html page of the website itself.

The step can go like this :

Step 8/16 : ADD https://sourceforge.net/projects/plantuml/files/${PLANTUML_VERSION}/plantuml.${PLANTUML_VERSION}.jar/download /usr/local/plantuml/plantuml.jar
Downloading [==================================================>]   8.67MB/8.67MB 
 ---> Using cache 
 ---> a63d7444537b

Or like this :

Step 8/16 : ADD https://sourceforge.net/projects/plantuml/files/${PLANTUML_VERSION}  /plantuml.${PLANTUML_VERSION}.jar/download /usr/local/plantuml/plantuml.jar 
Downloading    335kB

Any idea of what's causing this behavior ?

1

There are 1 answers

1
DannyB On

Sourceforge URLs are HTMLs that redirect to the downloaded file (they have both a Location header and a body).

You can see this behavior by opening the same URL you showed in a browser. You will see that it first loads an HTML, and only then "redirects" to the file download.

You will need to find another source, or resort to downloading it by other means, such as:

RUN wget -O plantuml.jar https://sourceforge.net/projects/plantuml/files/1.2020.19/plantuml.1.2020.19.jar/download