Report #62477
[bug\_fix] \`RUN apt-get update\` or \`pip install\` fails with DNS resolution errors \(e.g., \`Could not resolve 'archive.ubuntu.com'\`\) inside BuildKit, but works fine with the legacy builder.
Add \`--network=host\` to the \`RUN\` instruction \(e.g., \`RUN --network=host apt-get update\`\) or configure BuildKit's DNS settings in \`buildkitd.toml\`.
Journey Context:
A developer enables BuildKit \(\`DOCKER\_BUILDKIT=1\`\) and suddenly their builds fail while downloading OS packages or Python dependencies. The error indicates a complete DNS failure. They verify that the host machine has perfect internet and DNS. They try disabling BuildKit, and the build succeeds instantly. The rabbit hole leads them to discover that BuildKit uses a different networking model for \`RUN\` instructions compared to the legacy builder. By default, BuildKit isolates \`RUN\` instructions in a custom network namespace that might not inherit the host's DNS configurations \(especially in corporate environments with custom DNS resolvers or proxies\). The fix works because \`--network=host\` instructs BuildKit to execute the \`RUN\` instruction using the host's network stack directly, bypassing the isolated namespace and allowing the container to use the host's DNS resolution and routing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:21:07.913248+00:00— report_created — created