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 11, 2024
1 parent a056de8 commit 42decd8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/manuals/engine/network/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,40 @@ 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` 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 81 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": 81, "column": 68}}}, "severity": "INFO"}
the `ipvlan` network's gateway must be the default gateway.

The default gateway is selected by docker, and may change each time a
container's network connections change.
To make docker choose a specific default gateway when creating the container

Check failure on line 86 in content/manuals/engine/network/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.Capitalization] Please capitalize Docker. Raw Output: {"message": "[Docker.Capitalization] Please capitalize Docker.", "location": {"path": "content/manuals/engine/network/_index.md", "range": {"start": {"line": 86, "column": 8}}}, "severity": "ERROR"}
or connecting a new network, set a gateway priority. See option `gw-priority`
in [docker run](/reference/cli/docker/container/run.md) and
[docker network connect](/reference/cli/docker/network/connect.md).

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

Check failure on line 96 in content/manuals/engine/network/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.Capitalization] Please capitalize Docker. Raw Output: {"message": "[Docker.Capitalization] Please capitalize Docker.", "location": {"path": "content/manuals/engine/network/_index.md", "range": {"start": {"line": 96, "column": 2}}}, "severity": "ERROR"}
$ docker network connect anet2 myctr

Check failure on line 97 in content/manuals/engine/network/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.Capitalization] Please capitalize Docker. Raw Output: {"message": "[Docker.Capitalization] Please capitalize Docker.", "location": {"path": "content/manuals/engine/network/_index.md", "range": {"start": {"line": 97, "column": 2}}}, "severity": "ERROR"}
```

## Container networks

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

0 comments on commit 42decd8

Please sign in to comment.