The Network Drivers

One Flag, Very Different Networks

So far every network you've created has quietly used the bridge driver - Docker's default private virtual switch. A driver is simply the underlying implementation a network uses; swapping it changes how containers connect to the world, without changing anything about how you write your app. Bridge covers almost every case in this track, but it's worth knowing the alternatives exist, because production infrastructure sometimes needs them:

DriverWhat it doesWhen
bridgeprivate virtual switch + NAT (the default)almost everything
hostcontainer shares the host's network stack - no isolation, no -p neededmax network performance, port-scanning tools
noneno network at allbuild jobs, security-sensitive batch work
macvlancontainer gets its own MAC/IP on the physical LANlegacy appliances that must see a "real" device
overlayone virtual network spanning multiple hostsSwarm/multi-host (Kubernetes has its own model)
$ docker run --network host nginx      # nginx binds host:80 directly
$ docker run --network none alpine     # loopback only
Warning: --network host means the container can reach everything the host can - localhost services, the metadata endpoint in cloud VMs, other containers' published ports. Treat it as a privilege, not a convenience.

Static addressing - firewalls and legacy systems sometimes require a fixed source IP. That needs a network with an explicit subnet:

$ docker network create --subnet 172.28.0.0/16 legacynet
$ docker run -d --network legacynet --ip 172.28.0.50 gateway