Interview Prep/Docker/Networking and Compose

You need containers on different hosts to communicate privately.

AdvancedScenarioNetworking and Compose
Answer

Situation read → Bridge networks are host-local.

What I'd do → Docker Swarm overlay network (docker network create -d overlay --attachable --opt encrypted app), which uses VXLAN on UDP 4789 plus ports 2377/7946. Otherwise use Kubernetes CNI, or WireGuard mesh between hosts.

Why → Overlay encapsulates traffic across hosts; --opt encrypted adds IPsec at a CPU cost.

Interview tip → Open firewall ports 2377/tcp, 7946/tcp+udp, 4789/udp.

All Docker questions Roadmap: Docker & containers

More on Networking and Compose