We're a somewhat popular hosting provider that runs Docker containers (as VMs) for our customers and does private networking over IPv6, which expands the size of our DNS requests, and we run into this all the time with Alpine. It's kind of baffling.<p>TCP DNS is not hard. It's part of the spec. Normally, that argument doesn't mean much to me --- lots of things are parts of specs that I think are silly and not worth doing --- but TCP DNS seems like a basic necessity for DNS to work at all.<p>What's holding this up? TCP DNS is just UDP DNS, but over a TCP connection, with the packet length sent before the packet itself. It's the simplest thing you could possibly come up with to make TCP DNS work. It's been there since the 1980s. They should add it.
The moment I saw Alpine Linux in the title, my first guess was "I bet this is something to do with musl libc". Briefly looking through the blog, it looks like my gut feeling was correct.<p>A while ago I evaluated Alpine Linux. I wanted to like it, I really did, it ticked so many boxes.<p>But time and time again, I kept on running into issues with their adoption of musl libc.<p>The last straw for me was when I discovered packages in their package repo (some of which were well-known names) that were compiled against musl when the upstream developers quite clearly wrote in their docs that "if you compile X against anything other than glibc, you're on your own". For me, the fact that Alpine ignored this and compiled against musl anyway, was a big red flag. (And yes I raised some of these as bug reports, but the cases got closed and nothing done about it).
<i>> [...] the standard was extended by two options:</i><p><i>> - Increasing the size of the UPD packet above 512 bytes via the Extension Mechanism for DNS (EDNS)</i><p><i>> - Switching the protocol from UDP to TCP</i><p><i>> Alpine Linux, or rather musl libc, doesn’t support either of those options.</i><p>It still seems weird to me that such details are decided by libc. My reflex idea when designing a system would be to put DNS functionality in a system service, while libraries would only query the service, without troubling themselves with system caches, TCP vs UDP etc. Then possibly the service could be even swapped for another with a compatible interface, but making different decisions, without perturbing the applications. It sounds like systemd-resolved is a move in that direction, but I still don't understand why putting all that in libc, essentially making all applications perform their own independent DNS work, was the original choice.
We've run into DNS issues with Alpine containers at two different places I've worked at.
Completely different data centers and infra.<p>First time it took a lot of effort to pinpoint the problem.<p>Second time too, since it appeared because of a non-relevant code change (which lead to slighty more DNS requests).<p>In both cases, a simple switch to Debian slim saved the day.<p>Alpine is since banned from any env I'm working in :-)
DNS in Alpine is notoriously buggy but it can get months until you realise that.
One easy and effective solution is to force dns resolution like so<p>dnsConfig:
options:
- name: ndots
value: '1'<p>cc:
<a href="https://support.cloudbees.com/hc/en-us/articles/360040999471-UnknownHostException-caused-by-DNS-Resolution-issue-with-Alpine-Images" rel="nofollow">https://support.cloudbees.com/hc/en-us/articles/360040999471...</a><p>There are also plenty of dormant issue, enough so that I won't be using Alpine ever again imo :'(
Few days ago, I spent quite a few hours trying to make `apk update` work for alpine on WSL2 on Windows. It didn't want to resolve dl-cdn.alpinelinux.org within alpine. Did resolve on host ubuntu.<p>1. WFH from VPN, firstly I had to lower mtu from 1500 to 1392 (My VPN specific issue) <a href="https://github.com/microsoft/WSL/issues/4698" rel="nofollow">https://github.com/microsoft/WSL/issues/4698</a><p>2. Next, I had to run some powershell script that updates /etc/resolv.conf to use my VPN DNS (WSL specific stuff) <a href="https://github.com/microsoft/WSL/issues/1350" rel="nofollow">https://github.com/microsoft/WSL/issues/1350</a><p>3. And I still don't know if apk works properly. Kind of works in Docker build, but I have a feeling something not quite right.<p>See this example. Why does it "hang"? Docker command not exiting<p><pre><code> docker run -it alpine:3.15 apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
</code></pre>
Now, doing it within container itself, works:<p><pre><code> docker run -it alpine:3.15 sh
/ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-
cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
v3.15.0-342-g4fee739486 [https://dl-cdn.alpinelinux.org/alpine/v3.15/main]
v3.15.0-340-g4ed6115e99 [https://dl-cdn.alpinelinux.org/alpine/v3.15/community]
OK: 15859 distinct packages available
/ # exit
</code></pre>
Can someone shed some light?
There are two problems here:<p>• musl should support EDNS and DNS over TCP/IP without issues<p>• People should be smart enough to use DNS services that don't have stupid edge cases<p>For the latter, if you use Google for resolving DNS, you get what you deserve. Run your own resolver if DNS resolution matters.
In my experience, the storage, bandwidth and time savings using Alpine Linux (even if they were much more significant than they are in practice) are not worth it given the issues you run into every once in a while. Just go with Ubuntu/Debian base images and you'll be much happier that you did in the long run.