curl "(6) Could not resolve host" inside a CI container
Error 6 is a pure DNS failure: curl never got an IP address for the hostname, so no connection was even attempted. Inside a CI container this usually means the container has no working resolver: an empty or wrong /etc/resolv.conf, a DNS server that is unreachable from the container network, or a name that only resolves inside a private zone the runner cannot reach.
What this error means
curl fails with "curl: (6) Could not resolve host: example.com". Reaching the same host by IP works, and other containers on the network may resolve fine.
curl: (6) Could not resolve host: registry.internal.example.comCommon causes
The container has no working resolver
The container's /etc/resolv.conf is empty, points at an unreachable nameserver, or was not populated by the container runtime.
The name is private and not visible to the runner
An internal hostname resolves only via a private DNS zone or VPC resolver the CI network cannot reach.
How to fix it
Confirm and fix the resolver
- Print
/etc/resolv.confinside the container to see which nameservers it uses. - Test resolution directly with
getent hosts <name>ornslookup. - Configure a reachable DNS server for the container (for example the Docker daemon
--dnsoption or a composedns:entry).
cat /etc/resolv.conf
getent hosts registry.internal.example.com || echo "no DNS answer"Provide DNS for service containers
For a container that must resolve a private name, point it at the resolver that serves that zone.
services:
app:
image: my-app
dns:
- 10.0.0.2How to prevent it
- Verify
/etc/resolv.confis populated in custom container images. - Give containers explicit DNS servers when they must reach private zones.
- Test name resolution in a setup step before the first network call.