@@ -44,7 +44,7 @@ Here are some examples:
44
44
> the outside world as well.
45
45
>
46
46
> If you include the localhost IP address (` 127.0.0.1 ` , or ` ::1 ` ) with the
47
- > publish flag, only the Docker host.
47
+ > publish flag, only the Docker host can access the published container port .
48
48
>
49
49
> ``` console
50
50
> $ docker run -p 127.0.0.1:8080:80 -p ' [::1]:8080:80' nginx
@@ -138,18 +138,31 @@ rules are still set up so that only published container ports are accessible.
138
138
Outgoing packets from the container will use the container's address,
139
139
not a host address.
140
140
141
- In ` nat ` mode, when a port is published to a specific host address, that
142
- port is only accessible via the host interface with that address. So,
143
- for example, publishing a port to an address on the loopback interface
144
- means remote hosts cannot access it.
145
-
146
- However, using direct routing, published container ports are always
147
- accessible from remote hosts, unless the Docker host's firewall has
148
- additional restrictions. Hosts on the local layer-2 network can set up
141
+ To access a published port in a ` routed ` network, remote hosts must have
142
+ a route to the container network via an external address on the Docker
143
+ host ("direct routing"). Hosts on the local layer-2 network can set up
149
144
direct routing without needing any additional network configuration.
150
145
Hosts outside the local network can only use direct routing to the
151
146
container if the network's routers are configured to enable it.
152
147
148
+ In a ` nat ` mode network, publishing a port to an address on the loopback
149
+ interface means remote hosts cannot access it. Other published container
150
+ ports in ` routed ` and ` nat ` networks are always accessible from remote
151
+ hosts using direct routing, unless the Docker host's firewall has additional
152
+ restrictions.
153
+
154
+ > [ !NOTE]
155
+ >
156
+ > When a port is published to a specific host address in ` nat ` mode, if
157
+ > IP forwarding is enabled on the Docker host, the published port can be
158
+ > accessed via other host interfaces using direct routing to the host
159
+ > address.
160
+ >
161
+ > For example, a Docker host with IP forwarding enabled has two NICs with
162
+ > addresses ` 192.168.100.10/24 ` and ` 10.0.0.10/24 ` .
163
+ > When a port is published to ` 192.168.100.10 ` , a host in the ` 10.0.0.0/24 `
164
+ > subnet can access that port by routing to ` 192.168.100.10 ` via ` 10.0.0.10 ` .
165
+
153
166
In ` nat-unprotected ` mode, unpublished container ports are also
154
167
accessible using direct routing, no port filtering rules are set up.
155
168
This mode is included for compatibility with legacy default behaviour.
@@ -269,11 +282,12 @@ For example:
269
282
270
283
> [ !NOTE]
271
284
>
272
- > - Setting the default binding address to ` :: ` means port bindings with no host
273
- > address specified will work for any IPv6 address on the host. But, ` 0.0.0.0 `
274
- > means any IPv4 or IPv6 address.
275
- > - Changing the default bind address doesn't have any effect on Swarm services.
276
- > Swarm services are always exposed on the ` 0.0.0.0 ` network interface.
285
+ > Setting the default binding address to ` :: ` means port bindings with no host
286
+ > address specified will work for any IPv6 address on the host. But, ` 0.0.0.0 `
287
+ > means any IPv4 or IPv6 address.
288
+ >
289
+ > Changing the default bind address doesn't have any effect on Swarm services.
290
+ > Swarm services are always exposed on the ` 0.0.0.0 ` network interface.
277
291
278
292
### Default bridge
279
293
0 commit comments