Fix container DNS resolution broken by AAAA/IPv6 NXDOMAIN handling #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
In Alpine Linux containers (commonly used as Docker base images), standard DNS resolution is provided by musl, a lightweight C standard library (libc). Musl implements DNS lookups via
getaddrinfo(), which queries AAAA (IPv6) records first.Observed problem
DNS did not work correctly inside containers. Any system command attempting to resolve hostnames (e.g.,
ping dynamodb-admin) failed when the DNS server responded NXDOMAIN for AAAA records, even if A (IPv4) records existed. Explicitly forcing IPv4 (ping -4 dynamodb-admin) worked correctly, showing the issue is specific to musl’s IPv6-first behavior.Consequence
In IPv4-only environments, Alpine-based containers cannot resolve hostnames using standard tools or libraries. Applications relying on
getaddrinfo()fail with ENOTFOUND, breaking networking and inter-container communication.Root cause
Following RFC 8305 / RFC 6724, musl treats NXDOMAIN for AAAA as “hostname does not exist” and does not fallback to A (IPv4) records.
Fix implemented
The Apple Container DNS engine now behaves as follows:
This ensures that Alpine-based containers in IPv4-only networks can correctly resolve hostnames inside containers without modifying container images or application code.
Reproduction steps (Apple Container CLI 0.5.0)
Observed: resolution fails (NXDOMAIN / ENOTFOUND).
Workaround: explicitly forcing IPv4 works.
If comments in source are not required please remove them or let me know.
Testing