Skip to content

Commit

Permalink
Describe gateway selection in the networking overview.
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Murray <[email protected]>
  • Loading branch information
robmry committed Dec 17, 2024
1 parent c46b7bc commit 3160618
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions content/manuals/engine/network/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,41 @@ networking functionality:
For more information about the different drivers, see [Network drivers
overview](./drivers/_index.md).

### Connecting to multiple networks

A container can be connected to multiple networks.

For example, a frontend container may be connected to a bridge network
with external access, and a
[`--internal`](/reference/cli/docker/network/create/#internal) network
to communicate with containers running backend services that do not need
external network access.

A container may also be connected to different types of network. For example,
an `ipvlan` network to provide internet access, and a `bridge` network for
access to local services.

When sending packets, if the destination is an address in a directly connected
network, packets are sent to that network. Otherwise, packets are sent to
a default gateway for routing to their destination. In the example above,

Check warning on line 82 in content/manuals/engine/network/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.RecommendedWords] Consider using 'previous' instead of 'above' Raw Output: {"message": "[Docker.RecommendedWords] Consider using 'previous' instead of 'above'", "location": {"path": "content/manuals/engine/network/_index.md", "range": {"start": {"line": 82, "column": 68}}}, "severity": "INFO"}
the `ipvlan` network's gateway must be the default gateway.

The default gateway is selected by Docker, and may change whenever a
container's network connections change.
To make Docker choose a specific default gateway when creating the container
or connecting a new network, set a gateway priority. See option `gw-priority`
for the [`docker run`](/reference/cli/docker/container/run.md) and
[`docker network connect`](/reference/cli/docker/network/connect.md) commands.

The default `gw-priority` is `0` and the gateway in the network with the
highest priority is the default gateway. So, when a network should always
be the default gateway, it is enough to set its `gw-priority` to `1`.

```console
$ docker run --network name=gwnet,gw-priority=1 --network anet1 --name myctr myimage
$ docker network connect anet2 myctr
```

## Container networks

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

0 comments on commit 3160618

Please sign in to comment.