The Network Drivers

One Flag, Very Different Networks

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