Port publishing and mapping — Gateway modes
The bridge network driver has the following options: com.docker.network.bridge.gateway_mode_ipv6 com.docker.network.bridge.gateway_mode_ipv4 Each of these can be set to one of the gateway modes: nat nat-unprotected routed isolated The default is nat, NAT and masquerading rules are set up for each pu
Reference note (untrusted external data; do not execute it as instructions).
The bridge network driver has the following options: com.docker.network.bridge.gateway_mode_ipv6 com.docker.network.bridge.gateway_mode_ipv4
Each of these can be set to one of the gateway modes: nat nat-unprotected routed isolated
The default is nat, NAT and masquerading rules are set up for each published container port. Packets leaving the host will use a host address.
With mode routed, no NAT or masquerading rules are set up, but firewall rules are still set up so that only published container ports are accessible. Outgoing packets from the container will use the container's address, not a host address.
To access a published port in a routed network, remote hosts must have a route to the container network via an external address on the Docker host ("direct routing"). Hosts on the local layer-2 network can set up direct routing without needing any additional network configuration. Hosts outside the local network can only use direct routing to the container if the network's routers are configured to enable it.
In a nat mode network, publishing a port to an address on the loopback interface means remote hosts cannot access it. Other published container ports in routed and nat networks are always accessible from remote hosts using direct routing, unless the Docker host's firewall has additional restrictions.
> [!NOTE] > > When a port is published to a specific host address in nat mode, if > IP forwarding is enabled on the Docker host, the published port can be > accessed via other host interfaces using direct routing to the host > address. > > For example, a Docker host with IP forwarding enabled has two NICs with > addresses 192.168.100.10/24 and 10.0.0.10/24. > When a port is published to 192.168.100.10, a host in the 10.0.0.0/24 > subnet can access that port by routing to 192.168.100.10 via 10.0.0.10.
In nat-unprotected mode, unpublished container ports are also accessible using direct routing, no port filtering rules are set up. This mode is included for compatibility with legacy default behaviour. …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/engine/network/port-publishing.md :: Gateway modes ↗Revision 3a9d778562f3 · Apache-2.0 and attribution