Table of Contents
Docker network connectivity issues usually appear as containers being unable to reach the internet, other containers, or exposed services on a VPS.
Step 1: Verify Docker Is Running
Ensure Docker itself is active.
sudo systemctl status docker
If needed, restart Docker.
sudo systemctl restart docker
Step 2: Check Container Network Settings
Inspect the container’s network configuration.
docker inspect container_name
Look for IPAddress and Networks fields.
Step 3: Test Internet Connectivity from Inside the Container
Enter the container and test outbound access.
docker exec -it container_name sh
ping -c 3 google.com
If this fails, the issue is usually DNS or NAT-related.
Step 4: Fix Docker DNS Resolution
Docker sometimes inherits broken host DNS settings.
sudo nano /etc/docker/daemon.json
{
"dns": ["8.8.8.8", "1.1.1.1"]
}
Restart Docker after changes.
sudo systemctl restart docker
Step 5: Check iptables and NAT Rules
Docker relies on iptables for networking.
sudo iptables -t nat -L -n
If NAT rules are missing, Docker networking will fail.
Step 6: Recreate the Docker Network
Corrupted networks can cause connectivity issues.
docker network ls
docker network rm network_name
docker network create network_name
Reconnect containers to the new network.
Step 7: Check Host Firewall Conflicts
Firewalls may block container traffic.
sudo ufw status
sudo ufw disable
If connectivity works after disabling, adjust firewall rules properly.
You may also want to review this related article: [Internal Link: related article title]
Optional Step: Reset Docker Networking Completely
As a last resort, reset Docker networking.
docker network prune
sudo systemctl restart docker