How to Read Docker Networking
7 entriesMost container networking problems come from choosing the wrong network early, not from bugs in Docker. Docker attaches every container to at least one network, and the choice decides what the container can reach and what can reach it. Rules of thumb drawn from the Docker documentation: use a user-defined bridge network by default, because containers on it can find each other by name (containers on the default bridge can reach each other by IP address but not by name); use host networking only when the container should share the host's network stack; use none to cut a container off; use overlay when containers on several Docker hosts must share a network; use macvlan or ipvlan when a container must appear on the physical network; and publish only the ports that need outside access. This page collects the official documentation and tools for each concept. It is a learning guide, so check the Docker documentation for your Docker version before relying on a detail.
Core Concepts & Reference
7 entriesWhat a Docker network is and how to work with networks from the command line.
The Network Drivers
9 entriesBridge, host, none, overlay, macvlan and ipvlan, with what each trades between isolation and reach.
Names, DNS & Port Publishing
6 entriesHow containers find each other and how traffic gets in from outside.
Firewalls, Security & IPv6
6 entriesKeeping published ports and networks under control.
Docker Desktop, Swarm, Podman & Kubernetes
6 entriesWhere Docker networking differs on other platforms and runtimes.
Troubleshooting Tools & Source
5 entriesTools for inspecting traffic and the open-source engine itself.
Related Pages
7 entriesNeighbouring pages on this site.
Frequently Asked Questions
Why can't my containers find each other by name?
On the default bridge network, containers can reach each other by IP address but not by name. On a user-defined network (for example one created with docker network create), containers can use names or IP addresses. Put the containers on the same user-defined network, or use Docker Compose, which creates one for the application.
Which Docker network type should I use?
Start with a user-defined bridge for containers on one host. Use host networking when the container should share the host's network stack and you accept the loss of isolation, none to disable networking, overlay for containers across several Docker hosts in a swarm, and macvlan or ipvlan when a container must appear on the physical network.
Do published ports bypass my host firewall?
The Docker documentation says Docker creates its own firewall rules and that traffic to published ports is handled before it reaches the chains ufw uses, so ufw rules do not effectively control published ports. Limit exposure by publishing only what is needed, binding to 127.0.0.1 where possible, and reading the packet-filtering page for your Docker version.
How do I publish a port only to the Docker host?
Include the loopback address in the publish flag, for example -p 127.0.0.1:8080:80, so only the Docker host can reach it. Without a host address, Docker binds published ports to all host addresses.
Does host networking work on Docker Desktop?
Docker's documentation says host networking is an opt-in feature in Docker Desktop 4.34 and later, with limits such as working only at layer 4 and supporting only Linux containers.
Where does the information on this page come from?
Mainly the official Docker documentation, the Moby and netshoot repositories, and Wikipedia and Linux man pages for background. Docker changes its networking behaviour between versions, so check the documentation for your version.