Docker Build "Could not resolve host: deb.debian.org" in CI
By Kaveh Alemi·Latchkey
A RUN step could not resolve a hostname. Could not resolve host / Temporary failure in name resolution means DNS is not working for the build - no resolver, no network for the step, or a daemon DNS misconfiguration.
What this error means
A build step that downloads (apt, pip, npm, curl) fails with Could not resolve host: deb.debian.org or Temporary failure in name resolution. The host is reachable from the runner shell but not from inside the build.
docker
#8 0.42 W: Failed to fetch http://deb.debian.org/debian/... Could not resolve 'deb.debian.org'
#8 0.42 E: Some index files failed to download.
Common causes
No DNS resolver inside the build network
BuildKit steps use the builder network; if the daemon has no working DNS (empty/incorrect dns in daemon.json, broken resolv.conf), every name lookup fails.
The build step has no network
A --network=none step, or a builder with no egress, cannot resolve or reach anything.
Transient DNS blip on the runner
A momentary resolver failure on the host or upstream DNS can make a single build fail and pass on retry.
How to fix it
Set DNS for the daemon and confirm egress
Give the daemon working resolvers and make sure the build network reaches them.
A brief DNS blip clears on retry; a persistent failure is a config problem.
How to prevent it
Configure working dns resolvers in daemon.json on runner images.
Ensure the build network has outbound egress for download steps.
Avoid --network=none on steps that need DNS.
Frequently asked questions
What causes ""Could not resolve host" (build)"?
BuildKit steps use the builder network; if the daemon has no working DNS (empty/incorrect dns in daemon.json, broken resolv.conf), every name lookup fails.
How do I fix "Could not resolve host" (build)?
Give the daemon working resolvers and make sure the build network reaches them.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.