Skip to content

Commit d5d94e4

Browse files
committed
Explain how to use "network connect --driver-opt" to set sysctls
Signed-off-by: Rob Murray <rob.murray@docker.com>
1 parent 7f9dba6 commit d5d94e4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

docs/reference/commandline/network_connect.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ being connected to.
6565
$ docker network connect --alias db --alias mysql multi-host-network container2
6666
```
6767

68+
### <a name="sysctl"></a> Set sysctls for a container's interface (--driver-opt)
69+
70+
`sysctl` settings that start with `net.ipv4.` and `net.ipv6.` can be set per-interface
71+
using `--driver-opt` label `com.docker.network.endpoint.sysctls`. The name of the
72+
interface must be replaced by `IFNAME`.
73+
74+
To set more than one `sysctl` for an interface, quote the whole value of the
75+
`driver-opt` field, remembering to escape the quotes for the shell if necessary.
76+
For example, if the interface to `my-net` is given name `eth3`, the following example
77+
sets `net.ipv4.conf.eth3.log_martians=1` and `net.ipv4.conf.eth3.forwarding=0`.
78+
79+
```console
80+
$ docker network connect --driver-opt=\"com.docker.network.endpoint.sysctls=net.ipv4.conf.IFNAME.log_martians=1,net.ipv4.conf.IFNAME.forwarding=0\" multi-host-network container2
81+
```
82+
83+
> **Note**
84+
>
85+
> Network drivers may restrict the sysctl settings that can be modified and, to protect
86+
> the operation of the network, new restrictions may be added in the future.
87+
6888
### Network implications of stopping, pausing, or restarting containers
6989

7090
You can pause, restart, and stop containers that are connected to a network.

0 commit comments

Comments
 (0)