Use this when connecting containers to networks.
Networks
1. Container networks connect containers.
2. User-defined bridges for DNS between containers.
3. internal: true for isolation.
4. Publish only needed ports.
5. Avoid host network unless needed.
container → network → other containers
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as mutable tags, orphaned containers/networks, volume data loss, environment drift, restart loops, port collisions and running container mistaken for healthy application, choosing the cases most relevant to Docker network driver/scope, network IDs, service/container attachment, DNS/service discovery and connectivity after create/remove.
Step 2 Common mistakes Narrow the fault
- Default bridge for multi-container apps (no name resolution).
- Docker bypassing host firewall rules with published ports.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
docker network ls— networksdocker network inspect <net>— members- Internal networks for backends — isolation
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Container networks decide how containers reach each other and the outside world. On a single host, Docker creates bridge networks with built-in DNS, so containers on the same user-defined network find each other by service name.
| Network | Use |
|---|---|
| User-defined bridge | Default for Compose; name-based discovery |
| host | Container uses the host's network stack (no isolation, no port mapping) |
| macvlan/ipvlan | Container gets an address on the physical LAN |
| none | No networking |
docker network ls
docker network inspect netbox_default
docker exec netbox getent hosts postgres
Published ports (-p 8080:8080) bypass host firewall rules managed by ufw/firewalld in many setups because Docker inserts its own iptables rules; bind to 127.0.0.1:8080:8080 when a service should not be exposed.
Example
docker network create appnet
docker network inspect appnet
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Container Automation > Networks. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.docker.com/ · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For Docker network driver/scope, network IDs, service/container attachment, DNS/service discovery and connectivity after create/remove, prefer typed fields and stable IDs over human presentation text.