How does Docker networking work?medium

Type
conceptual
Topic
networking
Frequency
common
Tags
networking
Answer

Docker creates virtual networks. Containers on the same network can reach each other by container name. The default bridge network connects containers on the same host; host network removes isolation; overlay spans multiple hosts.

Explanation

In Docker Compose, each service gets a DNS entry matching its service name - a web service can reach a database service at db:5432 without knowing the IP. Port mapping ( -p 8080:80 ) exposes a container port to the host. User-defined bridge networks provide automatic DNS resolution; the default bridge does not. Overlay networks allow cross-host container communication in Docker Swarm.

Follow-upHow does container-to-container communication differ from host-to-container?