Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
When working inside a Docker container, you might need to verify DNS resolution β for example, to check if your container can reach another service or hostname.
However, many minimal base images (like Alpine, Debian-slim, or Ubuntu minimal) do not include the nslookup or dig commands.
So, what do you do when these tools are missing?
The answer: use the getent command. π
getent?getent is a Linux command that retrieves entries from system databases configured in /etc/nsswitch.conf.
Itβs part of the glibc library and is usually pre-installed β even in minimal images.
You can use it to query hosts, networks, users, groups, and more.
Run this inside your Docker container:
getent hosts example.comOutput example:
93.184.216.34 example.comThis confirms that the container can successfully resolve example.com using the DNS configuration defined inside the container (usually /etc/resolv.conf).
getent Instead of nslookup or dig?| Tool | Installed by default? | Uses system resolver? | Typical usage |
|---|---|---|---|
| nslookup | β No | β No (uses its own resolver) | Manual DNS check |
| dig | β No | β No (custom resolver) | Detailed DNS info |
| getent | β Usually Yes | β Yes | Same behavior as the system DNS resolver |
Because getent uses the same resolver as your application and system libraries, itβs more reliable for debugging real-world DNS issues inside containers.
/etc/resolv.confIf your Docker container doesnβt have nslookup or dig, donβt worry β getent is a lightweight, built-in command that provides reliable DNS resolution using the same resolver as your application.
Itβs a must-know tool for DevOps engineers troubleshooting network or DNS issues inside containers.