DELAPARRA
Index
Color
NL
Category: Docker

container DNS

Explained by Updated

What is container DNS?

container DNS: Docker runs an embedded DNS server on user-defined networks so containers resolve each other by name or alias. On a user-defined Docker network, Docker runs a small DNS server so containers can find each other by name. From the web container, the hostname db resolves to the database container's current IP address.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about container DNS

How is container DNS used in practice?

This is why Docker Compose files can use DB_HOST=db instead of IP addresses, which change whenever a container is recreated. You can also add aliases so a container answers to more than one name.

What should you keep in mind with container DNS?

Name resolution only works on user-defined networks, not on Docker's default bridge. Compose creates one for you. If ping db fails, check that both containers are on the same network with docker network inspect. And remember that service names are not reachable from your own computer's browser; for that you need a published port.

What does an example of container DNS look like?

# from the "web" container, on a shared network: ping db curl http://db:5432

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.