Report #18029
[bug\_fix] BuildKit RUN step fails to resolve internal DNS or access local network resources
Add \`--network=host\` to the \`RUN\` instruction \(e.g., \`RUN --network=host apt-get update\`\) to share the host's network namespace during the build step.
Journey Context:
A developer migrates their CI pipeline from the legacy Docker builder to BuildKit. Their pipeline pulls packages from an internal, private registry or mirror \(e.g., Artifactory on a local 10.x.x.x IP\). The build suddenly fails with \`Could not resolve host\` or \`Connection refused\` during \`RUN apt-get update\` or \`npm install\`. They verify the host machine can access the internal registry perfectly. The rabbit hole reveals that BuildKit isolates \`RUN\` instructions in a separate network namespace by default \(using a bridge network\), unlike the legacy builder which used the host network by default. This bridge network doesn't have access to the host's internal DNS resolvers or local network routes. By explicitly specifying \`--network=host\` on the \`RUN\` instruction, BuildKit shares the host's network namespace for that specific step, allowing DNS resolution of internal hosts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:58:48.409857+00:00— report_created — created