- All Courses
- Docker Essentials
- Working with Multiple Services
- Container networking
Container networking
On a user-defined network, containers resolve each other by name through the built-in DNS.
Overview
Containers find each other by name
On a user-defined network, containers resolve each other by name through the built-in DNS. An application connects to a database at its service name — no ip addresses, no discovery mechanism to build.
Publishing a port is only about reaching a container from the host. Two containers on the same network talk to each other without publishing anything, which is also the safer default.
From inside a container, localhost means that container. Trying to reach the host or a sibling that way is the most common networking mistake there is.
In this lesson you will:
- Connect containers on a user-defined network
- Resolve a service by container name
- Distinguish host ports from container ports
Resources
Notes are not saved yet — they clear when you leave this page.
Volumes and persistent data
10m
Docker Compose for local stacks
14m