beginnerDocker Networking: Bridge, Host, Overlay, DNS & Port Mapping

How does Docker route external traffic into a container?

Publishing a port (-p hostPort:containerPort) causes Docker to install an iptables DNAT (destination NAT) rule on the host. Traffic arriving at the host's published port is rewritten to target the container's internal IP and port on its bridge network, then delivered across the virtual ethernet (veth) pair into the container's network namespace.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to What is the difference between EXPOSE and -p in terms of networking?← Back to all Docker questions