Alpine and glibc, and the DNS resolution that is subtly different

Alpine uses musl rather than glibc, and musl’s resolver queries all configured nameservers in parallel and takes the first answer — which behaves differently from glibc under partial DNS failure.

# the symptom, intermittently, in a container that worked yesterday:
php_network_getaddresses: getaddrinfo failed: Try again

# musl also does not implement the search domain behaviour glibc has
# for names with dots in them, which breaks short service names in
# some cluster DNS setups.

# the pragmatic check before choosing alpine:
$ getent hosts mysql
$ nslookup mysql

The image size difference is real — around 70 MB against 400 for a Debian-based PHP image — and for most applications that is worth having. The failure mode is intermittent rather than consistent, which is why it costs a day when it happens: everything works for weeks and then one deploy sits behind a flaky resolver. Knowing that musl is the difference turns an unexplainable network problem into a known one with a documented workaround.