Skip to content

Commit 3160618

Browse files
committed
Describe gateway selection in the networking overview.
Signed-off-by: Rob Murray <[email protected]>
1 parent c46b7bc commit 3160618

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

content/manuals/engine/network/_index.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ networking functionality:
6363
For more information about the different drivers, see [Network drivers
6464
overview](./drivers/_index.md).
6565

66+
### Connecting to multiple networks
67+
68+
A container can be connected to multiple networks.
69+
70+
For example, a frontend container may be connected to a bridge network
71+
with external access, and a
72+
[`--internal`](/reference/cli/docker/network/create/#internal) network
73+
to communicate with containers running backend services that do not need
74+
external network access.
75+
76+
A container may also be connected to different types of network. For example,
77+
an `ipvlan` network to provide internet access, and a `bridge` network for
78+
access to local services.
79+
80+
When sending packets, if the destination is an address in a directly connected
81+
network, packets are sent to that network. Otherwise, packets are sent to
82+
a default gateway for routing to their destination. In the example above,
83+
the `ipvlan` network's gateway must be the default gateway.
84+
85+
The default gateway is selected by Docker, and may change whenever a
86+
container's network connections change.
87+
To make Docker choose a specific default gateway when creating the container
88+
or connecting a new network, set a gateway priority. See option `gw-priority`
89+
for the [`docker run`](/reference/cli/docker/container/run.md) and
90+
[`docker network connect`](/reference/cli/docker/network/connect.md) commands.
91+
92+
The default `gw-priority` is `0` and the gateway in the network with the
93+
highest priority is the default gateway. So, when a network should always
94+
be the default gateway, it is enough to set its `gw-priority` to `1`.
95+
96+
```console
97+
$ docker run --network name=gwnet,gw-priority=1 --network anet1 --name myctr myimage
98+
$ docker network connect anet2 myctr
99+
```
100+
66101
## Container networks
67102

68103
In addition to user-defined networks, you can attach a container to another

0 commit comments

Comments
 (0)