0

I am recieving a DNS error when attempting to build a docker image on a system configured as follows:

  • Base Image: Alpine 3.18 or 3.15
  • Docker Version: 24.0.5
  • OS running Docker: Linux Mint 21.1 Vera (Ubuntu 22.04)
  • In a VMware VM on a Windows host

I am not using a proxy.

My Dockerfile is

FROM alpine:3.18
RUN apk add --no-cache rsync

When attempting to build, I recieve a DNS error:

fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/main: DNS lookup error
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/community: DNS lookup error
4 unavailable, 0 stale; 15 distinct packages available

Running a stand-alone container sucessfully resolves the address

docker run --rm alpine:3.18 nslookup dl-cdn.alpinelinux.org

Server:         192.168.94.2
Address:        192.168.94.2:53

Non-authoritative answer:
dl-cdn.alpinelinux.org  canonical name = dualstack.j.sni.global.fastly.net
Name:   dualstack.j.sni.global.fastly.net
Address: 2a04:4e42:1f::644

Non-authoritative answer:
dl-cdn.alpinelinux.org  canonical name = dualstack.j.sni.global.fastly.net
Name:   dualstack.j.sni.global.fastly.net
Address: 151.101.134.132

But I am unable to ping or do an apk update by name

docker run --rm alpine:3.18 ping -c 1 dl-cdn.alpinelinux.org
ping: bad address 'dl-cdn.alpinelinux.org'

Although pinging by IP works.

scott@spruce:\~$ docker run --rm alpine:3.18 ping -c 1 151.101.134.132
PING 151.101.134.132 (151.101.134.132): 56 data bytes
64 bytes from 151.101.134.132: seq=0 ttl=127 time=32.607 ms

\--- 151.101.134.132 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 32.607/32.607/32.607 ms

The following do not work, as suggested here, or here


docker run --rm alpine:3.18 apk update
docker run --rm --network=host alpine:3.18 apk update
docker run --rm --dns=8.8.8.8 alpine:3.18 apk update

Additionally, configuring netplan with 'en*', as per this answer also did not help.

This also seems somewhat base-image specific, as I am not having any issues building Ubuntu-based images (specificially the python 3.5 images)

How do I configure networking for this Ubuntu/Alpine combination?

ScottP
  • 13
  • 4

1 Answers1

0

I believe I was able to resolve this by setting the --add-host directive

docker image build --add-host "dl-cdn.alpinelinux.org:151.101.134.132" .

What's strange is that doing this once seemed to fix it for building any other image based on alpine:3.18 as well and I don't seem to need it anymore if building a completly different alpine-based image. I can't rule out that it's a new day and something else changed though. (e.g. power cycled the person).

ScottP
  • 13
  • 4