Default Docker networks
When Docker is installed, it creates three default networks:bridge, host, and none. Use docker run --network to choose a network at runtime or attach containers to networks you create.
Using
--network host removes network namespace isolation. Ports opened by the container are exposed directly on the host, so you cannot run multiple containers that bind the same host port when using host networking.- Docker creates a private bridge interface on the host (commonly
docker0). - Containers attached to this bridge receive internal IP addresses (often in
172.17.0.0/16) and can reach each other by those IPs. - To reach containers externally, map container ports to host ports (for example:
-p 8080:80).
--network hostmakes the container share the host’s network stack.- Container ports are accessible on the host without port mapping.
- Port conflicts can occur because containers use the host port namespace.
nonegives a container no network interfaces except loopback and prevents external connectivity.
Isolating containers with user-defined networks
If you want to isolate sets of containers on the same host (so they cannot reach each other by default), create user-defined bridge networks with custom subnets. Containers on the same user-defined network can communicate using container names, and Docker provides an embedded DNS server for that network.
Inspecting container network settings
To view a container’s IP address, gateway, and other network settings, usedocker inspect:
Name resolution: container names vs IPs
Using IP addresses to connect to containers is brittle because IPs may change (for example, after a restart). Prefer resolving containers by name where possible.- On the default
bridgenetwork, there is no embedded DNS for container names — containers can reach each other only by IP. - On user-defined networks (including networks created by Docker Compose), Docker provides an embedded DNS server at
127.0.0.11. This DNS resolves container names to their IP addresses for containers on that network.
- Create a user-defined network.
- Run both database and web app attached to that network.
- Use the database container name (e.g.
mysql) as the hostname in your app config.
Docker Compose automatically creates a user-defined network for each project. That is why service names in a Compose file act as DNS names for inter-service communication:
Under the hood
Docker networking is built on Linux kernel mechanisms:- Network namespaces: each container typically has its own network namespace to isolate network resources.
- Virtual Ethernet (veth) pairs: veth pairs connect a container’s network namespace to the host bridge or to another namespace.

Summary & next steps
- Use user-defined bridge networks to enable service name resolution and isolate groups of containers.
- Avoid relying on container IPs; prefer container names on user-defined networks.
- Use
docker network inspect,docker inspect, anddocker network lsto debug networking issues.