Docker DNS & Networking Fixes
What this is
Reference for fixing Docker container networking and DNS resolution issues within my homelab.
Why I needed this
Containers were unable to resolve hostnames or access external services reliably.
This caused issues with updates, API calls, and inter-container communication.
Where this applies
-
Mainly on: micropc
-
Docker-based services across both hosts
-
Affects containers using default bridge networking
Symptoms
-
Containers cannot resolve domains:
ping google.com → fails -
Slow or failed internet access inside containers
-
Services unable to reach APIs or external endpoints
-
Intermittent networking issues
Root Cause (Observed)
-
Docker DNS not reliably using router DNS
-
Inconsistent DNS resolution inside containers
-
Possible MTU mismatch causing packet issues
Fix: Docker Daemon Configuration
Edit:
sudo nano /etc/docker/daemon.json
Add / update:
{
"dns": ["192.168.86.1", "8.8.8.8", "1.1.1.1"],
"ipv6": false,
"mtu": 1380
}
Apply Changes
Restart Docker:
sudo systemctl restart docker
Key Configuration Notes
DNS Servers
-
192.168.86.1→ local router (primary) -
8.8.8.8→ Google DNS (fallback) -
1.1.1.1→ Cloudflare DNS (fallback)
MTU Setting
-
Set to
1380 -
Helps avoid packet fragmentation issues
-
Especially important when using:
-
VPNs
-
Cloudflare Tunnel
-
IPv6
-
Disabled (
ipv6: false) -
Avoids conflicts where IPv6 is partially configured but not functional
Verification Steps
Test DNS inside container
docker exec -it <container_name> ping google.com
Test HTTP connectivity
docker exec -it <container_name> curl https://example.com
Check container DNS config
docker exec -it <container_name> cat /etc/resolv.conf
Common Problems / Fixes
DNS still not resolving
-
Restart affected containers:
docker restart <container_name>
Only some containers affected
-
Check if container overrides DNS
-
Verify network mode (bridge vs host)
Issues after reboot
-
Ensure Docker starts after network is ready
-
Confirm
/etc/docker/daemon.jsonis still applied
Host works but containers don’t
-
Confirms Docker-level DNS issue
-
Re-check daemon.json configuration
Result
-
Stable DNS resolution across all containers
-
Reliable external connectivity
-
No more intermittent network failures
Notes
-
Applies globally to all containers on host
-
Important baseline configuration for homelab stability
-
Particularly relevant when using Cloudflare Tunnel
No comments to display
No comments to display