@@ -150,15 +150,51 @@ But, particularly with IPv6 you may prefer to avoid using NAT and instead
150
150
arrange for external routing to container addresses ("direct routing").
151
151
152
152
To access containers on a bridge network from outside the Docker host,
153
- you must set up routing to the bridge network via an address on the Docker
154
- host. This can be achieved using static routes, Border Gateway Protocol
155
- (BGP), or any other means appropriate for your network.
156
-
157
- Within a local layer 2 network, remote hosts can set up static routes
158
- to a container network using the Docker daemon host's address on the local
159
- network. Those hosts can access containers directly. For remote hosts
160
- outside the local network, direct access to containers requires router
161
- configuration to enable the necessary routing.
153
+ you must first set up routing to the bridge network via an address on the
154
+ Docker host. This can be achieved using static routes, Border Gateway Protocol
155
+ (BGP), or any other means appropriate for your network. For example, within
156
+ a local layer 2 network, remote hosts can set up static routes to a container
157
+ network via the Docker daemon host's address on the local network.
158
+
159
+ #### Direct routing to containers in bridge networks
160
+
161
+ By default, remote hosts are not allowed direct access to container IP
162
+ addresses in Docker's Linux bridge networks. They can only access ports
163
+ published to host IP addresses.
164
+
165
+ To allow direct access to any published port, on any container, in any
166
+ Linux bridge network, use daemon option ` --allow-direct-routing ` or the
167
+ equivalent ` "allow-direct-routing": true ` in ` /etc/docker/daemon.json ` .
168
+
169
+ To allow direct routing from anywhere to containers in a specific bridge
170
+ network, see [ Gateway modes] ( #gateway-modes ) .
171
+
172
+ Or, to allow direct routing via specific host interfaces, to a specific
173
+ bridge network, use the following option when creating the network:
174
+ - ` com.docker.network.bridge.trusted_host_interfaces `
175
+
176
+ #### Example
177
+
178
+ Create a network where published ports on container IP addresses can be
179
+ accessed directly from interfaces ` vxlan.1 ` and ` eth3 ` :
180
+
181
+ ``` console
182
+ $ docker network create --subnet 192.0.2.0/24 --ip-range 192.0.2.0/29 -o com.docker.network.bridge.trusted_host_interfaces=" vxlan.1:eth3" mynet
183
+ ```
184
+
185
+ Run a container in that network, publishing its port 80 to the port
186
+ 8080 on host's loopback interface:
187
+
188
+ ``` console
189
+ docker run -d --ip 192.0.2.100 -p 127.0.0.1:8080:80 nginx
190
+ ```
191
+
192
+ The web server running on the container's port 80 can now be accessed
193
+ from the Docker host at ` http://127.0.0.1:8080 ` , or directly at
194
+ ` http://192.0.2.100:80 ` . If remote hosts on networks connected to
195
+ interfaces ` vxlan.1 ` and ` eth3 ` have a route to the ` 192.0.2.0/24 `
196
+ network inside the Docker host, they can also access the web server
197
+ via ` http://192.0.2.100:80 ` .
162
198
163
199
#### Gateway modes
164
200
0 commit comments