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