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