Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0 Backport] docs: add default-network-opt daemon option #4639

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/reference/commandline/dockerd.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Options:
--default-gateway ip Container default gateway IPv4 address
--default-gateway-v6 ip Container default gateway IPv6 address
--default-ipc-mode string Default mode for containers ipc ("shareable" | "private") (default "private")
--default-network-opt mapmap Default network options (default map[])
--default-runtime string Default OCI runtime for containers (default "runc")
--default-shm-size bytes Default shm size for containers (default 64MiB)
--default-ulimit ulimit Default ulimits for containers (default [])
Expand Down Expand Up @@ -1449,6 +1450,7 @@ This is a full example of the allowed configuration options on Linux:
"default-cgroupns-mode": "private",
"default-gateway": "",
"default-gateway-v6": "",
"default-network-opts": {},
"default-runtime": "runc",
"default-shm-size": "64M",
"default-ulimits": {
Expand Down Expand Up @@ -1566,6 +1568,7 @@ This is a full example of the allowed configuration options on Windows:
"containerd-plugin-namespace": "docker-plugins",
"data-root": "",
"debug": true,
"default-network-opts": {},
"default-runtime": "",
"default-ulimits": {},
"dns": [],
Expand Down Expand Up @@ -1711,3 +1714,50 @@ $ sudo dockerd \
--data-root=/var/lib/docker-bootstrap \
--exec-root=/var/run/docker-bootstrap
```

### Default network options

The `default-network-opts` key in the `daemon.json` configuration file, and the
equivalent `--default-network-opt` CLI flag, let you specify default values for
driver network driver options for new networks.

The following example shows how to configure options for the `bridge` driver
using the `daemon.json` file.

```json
{
"default-network-opts": {
"bridge": {
"com.docker.network.bridge.host_binding_ipv4": "127.0.0.1",
"com.docker.network.bridge.mtu": "1234"
}
}
}
```

This example uses the `bridge` network driver. Refer to the
[bridge network driver page](https://docs.docker.com/network/drivers/bridge/#options)
for an overview of available driver options.

After changing the configuration and restarting the daemon, new networks that
you create use these option configurations as defaults.

```console
$ docker network create mynet
$ docker network inspect mynet --format "{{json .Options}}"
{"com.docker.network.bridge.host_binding_ipv4":"127.0.0.1","com.docker.network.bridge.mtu":"1234"}
```

Note that changing this daemon configuration doesn't affect pre-existing
networks.

Using the `--default-network-opt` CLI flag is useful for testing and debugging
purposes, but you should prefer using the `daemon.json` file for persistent
daemon configuration. The CLI flag expects a value with the following format:
`driver=opt=value`, for example:

```console
$ sudo dockerd \
--default-network-opt bridge=com.docker.network.bridge.host_binding_ipv4=127.0.0.1 \
--default-network-opt bridge=com.docker.network.bridge.mtu=1234
```
4 changes: 4 additions & 0 deletions man/dockerd.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dockerd - Enable daemon mode
[**--default-gateway**[=*DEFAULT-GATEWAY*]]
[**--default-gateway-v6**[=*DEFAULT-GATEWAY-V6*]]
[**--default-address-pool**[=*DEFAULT-ADDRESS-POOL*]]
[**--default-network-opt**[=*DRIVER=OPT=VALUE*]]
[**--default-runtime**[=*runc*]]
[**--default-ipc-mode**=*MODE*]
[**--default-shm-size**[=*64MiB*]]
Expand Down Expand Up @@ -186,6 +187,9 @@ $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-ru
Example: base=172.30.0.0/16,size=24 will set the default
address pools for the selected scope networks to {172.30.[0-255].0/24}

**--default-network-opt**=*DRIVER=OPT=VALUE*
Default network driver options

**--default-runtime**=*"runtime"*
Set default runtime if there're more than one specified by **--add-runtime**.

Expand Down
Loading