Skip to content

Commit 485e16c

Browse files
committed
docs: add default-network-opt daemon option
Signed-off-by: David Karlsson <[email protected]>
1 parent a6351d0 commit 485e16c

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

docs/reference/commandline/dockerd.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Options:
4646
--default-gateway ip Container default gateway IPv4 address
4747
--default-gateway-v6 ip Container default gateway IPv6 address
4848
--default-ipc-mode string Default mode for containers ipc ("shareable" | "private") (default "private")
49+
--default-network-opt mapmap Default network options (default map[])
4950
--default-runtime string Default OCI runtime for containers (default "runc")
5051
--default-shm-size bytes Default shm size for containers (default 64MiB)
5152
--default-ulimit ulimit Default ulimits for containers (default [])
@@ -1017,6 +1018,7 @@ This is a full example of the allowed configuration options on Linux:
10171018
"default-cgroupns-mode": "private",
10181019
"default-gateway": "",
10191020
"default-gateway-v6": "",
1021+
"default-network-opts": "",
10201022
"default-runtime": "runc",
10211023
"default-shm-size": "64M",
10221024
"default-ulimits": {
@@ -1134,6 +1136,7 @@ This is a full example of the allowed configuration options on Windows:
11341136
"containerd-plugin-namespace": "docker-plugins",
11351137
"data-root": "",
11361138
"debug": true,
1139+
"default-network-opts": "",
11371140
"default-runtime": "",
11381141
"default-ulimits": {},
11391142
"dns": [],
@@ -1279,3 +1282,50 @@ $ sudo dockerd \
12791282
--data-root=/var/lib/docker-bootstrap \
12801283
--exec-root=/var/run/docker-bootstrap
12811284
```
1285+
1286+
### Default network options
1287+
1288+
The `default-network-opts` key in the `daemon.json` configuration file, and the
1289+
equivalent `--default-network-opt` CLI flag, let you specify default values for
1290+
driver network driver options for new networks.
1291+
1292+
The following example shows how to configure options for the `bridge` driver
1293+
using the `daemon.json` file.
1294+
1295+
```json
1296+
{
1297+
"default-network-opts": {
1298+
"bridge": {
1299+
"com.docker.network.bridge.host_binding_ipv4": "127.0.0.1",
1300+
"com.docker.network.bridge.mtu": "1234"
1301+
}
1302+
}
1303+
}
1304+
```
1305+
1306+
This example uses the `bridge` network driver. Refer to the
1307+
[bridge network driver page](https://docs.docker.com/network/drivers/bridge/#options)
1308+
for an overview of available driver options.
1309+
1310+
After changing the configuration and restarting the daemon, new networks that
1311+
you create use these option configurations as defaults.
1312+
1313+
```console
1314+
$ docker network create mynet
1315+
$ docker network inspect mynet --format "{{json .Options}}"
1316+
{"com.docker.network.bridge.host_binding_ipv4":"127.0.0.1","com.docker.network.bridge.mtu":"1234"}
1317+
```
1318+
1319+
Note that changing this daemon configuration doesn't affect pre-existing
1320+
networks.
1321+
1322+
Using the `--default-network-opt` CLI flag is useful for testing and debugging
1323+
purposes, but you should prefer using the `daemon.json` file for persistent
1324+
daemon configuration. The CLI flag expects a value with the following format:
1325+
`driver=opt=value`, for example:
1326+
1327+
```console
1328+
$ sudo dockerd \
1329+
--default-network-opt bridge=com.docker.network.bridge.host_binding_ipv4=127.0.0.1 \
1330+
--default-network-opt bridge=com.docker.network.bridge.mtu=1234
1331+
```

man/dockerd.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dockerd - Enable daemon mode
2020
[**--default-gateway**[=*DEFAULT-GATEWAY*]]
2121
[**--default-gateway-v6**[=*DEFAULT-GATEWAY-V6*]]
2222
[**--default-address-pool**[=*DEFAULT-ADDRESS-POOL*]]
23+
[**--default-network-opt**[=*DRIVER=OPT=VALUE*]]
2324
[**--default-runtime**[=*runc*]]
2425
[**--default-ipc-mode**=*MODE*]
2526
[**--default-shm-size**[=*64MiB*]]
@@ -186,6 +187,9 @@ $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-ru
186187
Example: base=172.30.0.0/16,size=24 will set the default
187188
address pools for the selected scope networks to {172.30.[0-255].0/24}
188189

190+
**--default-network-opt**=*DRIVER=OPT=VALUE*
191+
Default network driver options
192+
189193
**--default-runtime**=*"runtime"*
190194
Set default runtime if there're more than one specified by **--add-runtime**.
191195

0 commit comments

Comments
 (0)