'How can I read and use url from an online file in dockerfile [closed]

I'm trying to create a Dockerfile that read some URLs from an online file but when I try to use wget with the URL in a variable, it fails. If I print the variables in a console message the result is the corrects URLs.

If the variables are declared with ENV or initialized with the URL I don't have problems to use it in the wget; the problem only happens when reading URLs from a file.

FROM openjdk:8

USER root
RUN mkdir /opt/tools /aplicaciones /deployments \
    && wget -q "www.url_online_file.com" -O url.txt \
    && while IFS== read -r name url; do if [ $name = "url1" ]; then export URL1=$url; fi; if [ $name = "url2" ]; then export URL2=$url; fi; done < url.txt \
    && echo "DEBUG URL1=$URL1"; echo "DEBUG URL2=$URL2"; \
    && wget -q $URL1 -O url1.zip

Error:

DEBUG URL1=www.prueba1.com
DEBUG URL2=www.prueba2.com
The command '/bin/sh -c mkdir /opt/tools /aplicaciones /deployments     && wget -q "www.url_online_file.com" -O url.txt     && while IFS== read -r name url; do if [ $name = "url1" ]; then export URL1=$url; fi; if [ $name = "url2" ]; then export URL2=$url; fi; done < url.txt  && echo "DEBUG URL1=$URL1"; echo "DEBUG URL2=$URL2";     && wget -q $URL1 -O url1.zip' returned a non-zero code: 8

The file.txt structure in online_file is:

url1=www.prueba1.com
url2=www.prueba2.com



Solution 1:[1]

The solution was used the command wget -i to the www.url_online_file.com and modified the content of the file to:

www.prueba1.com
www.prueba2.com

The dockerfile:

FROM openjdk:8

USER root
RUN mkdir /opt/tools /aplicaciones /deployments \
    && wget -i "www.url_online_file.com" \
    && && rm url* \
    && mv url1* url1.zip \
    && mv url2* url2.zip \
    && unzip url1.zip -d /opt/tools \
    && unzip url2.zip -d /opt/tools \
    && rm url1.zip \
    && rm url2.zip 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Victor Barrueco