How does Docker handle outbound traffic from a container to the internet?
AdvancedConceptNetworking
Answer
Packets leave via eth0 to the bridge, the host forwards them (needs net.ipv4.ip_forward=1, which Docker enables), and an iptables MASQUERADE rule rewrites the source to the host IP. If forwarding is disabled or a firewall drops FORWARD, containers cannot reach out and DNS lookups time out.
More on Networking
What network drivers does Docker have?BeginnerHow does the default bridge network work?AdvancedDefault bridge vs user-defined bridge: what is the difference?IntermediateHow does container DNS work?IntermediateHow does `-p 8080:80` work under the hood?AdvancedWhat is the difference between `-p 80:80` and `-p 127.0.0.1:80:80`?Beginner