1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [container DNS](<https://delaparra-services.nl/knowledge-hub/container-dns>)

  

Category: Docker 

# container DNS

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## 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](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/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[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More Docker terms

 

- [build](<https://delaparra-services.nl/knowledge-hub/build>) 
- [CMD](<https://delaparra-services.nl/knowledge-hub/cmd>) 
- [container](<https://delaparra-services.nl/knowledge-hub/container>) 
- [COPY](<https://delaparra-services.nl/knowledge-hub/copy>) 
- [depends\_on](<https://delaparra-services.nl/knowledge-hub/depends-on>) 
- [digest](<https://delaparra-services.nl/knowledge-hub/digest>)

 

[All terms starting with C](<https://delaparra-services.nl/knowledge-hub#letter-c>)

 

## Skills

 

- ### Docker Project Foundations

 

Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.

 [View skill](<https://delaparra-services.nl/skills/docker-project-foundations>) [Download zip](<https://delaparra-services.nl/skills/docker-project-foundations/download>) 
- ### Docker Compose Patterns

 

Use this skill when creating, modifying, or debugging Docker Compose configurations, even if the user just says they need to wire services together, add a database to their stack, or set up a local development environment with multiple containers. Covers service definitions, health checks, dependency ordering, volumes, networks, environment variables, and development overrides.

 [View skill](<https://delaparra-services.nl/skills/docker-compose-patterns>) [Download zip](<https://delaparra-services.nl/skills/docker-compose-patterns/download>) 
- ### Docker Build Strategies

 

Use this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.

 [View skill](<https://delaparra-services.nl/skills/docker-build-strategies>) [Download zip](<https://delaparra-services.nl/skills/docker-build-strategies/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/container-dns/skills.zip>)

 

## Manuals

 

- [Docker for your Laravel app](<https://delaparra-services.nl/manuals/docker-voor-je-laravel-app>) 
- [Deploying a Laravel app](<https://delaparra-services.nl/manuals/je-laravel-app-online-zetten>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.

 

## 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.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/container-dns)
