@@ -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+ ```
0 commit comments