Subodh Joshi
Subodh Joshi

Reputation: 13512

wget: bad address 'github.com'

I am using the wget inside the Dockerfile

    FROM wso2/wso2mi:4.0.0
COPY /lib/* $WSO2_SERVER_HOME/lib/
COPY /carFiles/common-20.11.0-SNAPSHOT.car $WSO2_SERVER_HOME/repository/deployment/server/carbonapps/
COPY jdk8.tar.gz $WORKING_DIRECTORY/
#Download and configure Java 8
RUN \
   # wget -O jdk8.tar.gz github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz; \
    mkdir -p ${WORKING_DIRECTORY}/openjdk-8; \
    cd ${WORKING_DIRECTORY}/openjdk-8; \
    tar -xf ${WORKING_DIRECTORY}/jdk8.tar.gz --strip-components=1; \
    export PATH=${WORKING_DIiRECTORY}/openjdk-8/bin:$PATH; \
    rm ${WORKING_DIRECTORY}/jdk8.tar.gz;

ENV JAVA_HOME=${WORKING_DIRECTORY}/openjdk-8 \
    PATH=${WORKING_DIRECTORY}/openjdk-8/bin:$PATH

But its failing with the error

wget: bad address 'github.com' tar: can't open '/home/wso2carbon/jdk8.tar.gz': No such file or directory rm: can't remove '/home/wso2carbon/jdk8.tar.gz': No such file or directory

i am trying to build the image with this Docker command

docker build -f  Dockerfile -t myimage:21.0.82   .

then as per the another SO post

docker build -f  Dockerfile -t myimage:21.0.82  --network host .

this also failed with same issue .

If directly i am using

wget -O jdk8.tar.gz https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz;

its working fine without any issue . Is this a Dockerfile issue or wget?

Even this SO post not helped .

Upvotes: 2

Views: 14653

Answers (1)

user2745509
user2745509

Reputation: 461

TL;DR One of DNS'es in /etc/resolv.conf responds with "bad address", get rid of it. Either by replacing that config or using --dns <DNS_IP> docker option.

Alpine images have both default wget (busybox built-in one) and wget package built with musl. Musl queries DNS'es in a different way:

"Traditional resolvers, including glibc’s, make use of multiple nameserver lines in resolv.conf by trying each one in sequence and falling to the next after one times out. musl’s resolver queries them all in parallel and accepts whichever response arrives first." https://wiki.musl-libc.org/functional-differences-from-glibc.html#Name-Resolver/DNS

Hence if a "faulty" DNS responds first, you get a "bad address". In my case I had VPN DNS and a regular DNS which would respond different. Helped to drop one.

Upvotes: 0

Related Questions