When the Container Can’t Reach Anything: DNS Inside the Image

A sign-in that failed with ENETUNREACH, and why the base image was the culprit.

When the Container Can't Reach Anything: a glowing crate signalling for a lighthouse it can't find in the fog

Symptom: a small Node service in a containercontainer A lightweight, isolated package of an application and its dependencies. It shares the host's kernel, so it starts in seconds, unlike a full virtual machine. failed to sign in to its cloud API with ENETUNREACH. The host had internet. Other containers had internet. This one didn’t.

Cause: the image was built on Alpine. Inside it, the API’s hostname resolved to IPv6IPv6 The newer internet addressing scheme, with vastly more addresses than IPv4. Mixed IPv4/IPv6 setups are a classic source of 'it works here but not there' bugs. addresses only, and the container had no IPv6 route. Node tried the address it was given, and the network said no.

Fix: rebuild on a Debian slim base image. Its resolver returned IPv4 addresses as well, and the sign-in worked on the first try. I left a comment in the Dockerfile explaining why, so future me doesn’t “optimize” back to Alpine.

Check it yourself:

docker exec -it <container> getent ahosts example.com
docker exec -it <container> node -e "require('dns').lookup('example.com',{all:true},(e,a)=>console.log(a))"

Lesson: “the network is fine” usually means “the host’s network is fine”. The container has its own resolver, its own libc and its own opinions. Test from inside.

Applies to: Node.js containers on Alpine-based images versus Debian slim, on a DockerDocker A tool for packaging software and everything it needs into containers, so it runs the same way on any machine. host without IPv6 routing. Checked October 2026.

ᛟ ᛟ ᛟ