SteelReed

Search

Search posts, questions…

DevOps & CloudQuestion 12 / 35

Junior

What is a Docker network? How do containers reach each other by name, and which network types exist?

Short answer

Every container has its own network namespace; containers on the same network call each other directly, and on a user-defined network they can call by name thanks to Docker's internal DNS. Common drivers: bridge (one host), host, none, overlay (many hosts).

db:5432returns db IPlocalhostdocker network create shopContainer appContainer dbInternal DNS 127.0.0.11The app container itself

3 points to say:

  1. The default bridge only allows calls by IP; a user-defined bridge has name-based DNS and isolates by network.
  2. localhost inside a container is the container itself, not the host; containers on one network use the original port, no -p needed.
  3. host uses the machine's network directly, none has no network, overlay spans hosts; Kubernetes uses CNI, not Docker networks.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.