@@ -5,14 +5,15 @@ Connect a container to a network
55
66### Options
77
8- | Name | Type | Default | Description |
9- | :--------------------| :--------------| :--------| :-------------------------------------------|
10- | [ ` --alias ` ] ( #alias ) | ` stringSlice ` | | Add network-scoped alias for the container |
11- | ` --driver-opt ` | ` stringSlice ` | | driver options for the network |
12- | [ ` --ip ` ] ( #ip ) | ` string ` | | IPv4 address (e.g., ` 172.30.100.104 ` ) |
13- | ` --ip6 ` | ` string ` | | IPv6 address (e.g., ` 2001:db8::33 ` ) |
14- | [ ` --link ` ] ( #link ) | ` list ` | | Add link to another container |
15- | ` --link-local-ip ` | ` stringSlice ` | | Add a link-local address for the container |
8+ | Name | Type | Default | Description |
9+ | :----------------------| :--------------| :--------| :---------------------------------------------------------|
10+ | [ ` --alias ` ] ( #alias ) | ` stringSlice ` | | Add network-scoped alias for the container |
11+ | ` --driver-opt ` | ` stringSlice ` | | driver options for the network |
12+ | [ ` --ip ` ] ( #ip ) | ` string ` | | IPv4 address (e.g., ` 172.30.100.104 ` ) |
13+ | ` --ip6 ` | ` string ` | | IPv6 address (e.g., ` 2001:db8::33 ` ) |
14+ | [ ` --link ` ] ( #link ) | ` list ` | | Add link to another container |
15+ | ` --link-local-ip ` | ` stringSlice ` | | Add a link-local address for the container |
16+ | [ ` --sysctl ` ] ( #sysctl ) | ` stringSlice ` | | short-form interface sysctl: net.X.Y.ethN.Z=V -> X.Y.Z=V |
1617
1718
1819<!-- -MARKER_GEN_END-->
@@ -23,6 +24,14 @@ Connects a container to a network. You can connect a container by name
2324or by ID. Once connected, the container can communicate with other containers in
2425the same network.
2526
27+ The ` --sysctl ` option in ` network connect ` is restricted to sysctls that start with
28+ ` net.ipv4. ` and ` net.ipv6. ` . The ` net. ` prefix and the name of the interface must
29+ not be included. Internally, the sysctl options are added to ` DriverOpts ` with the
30+ key ` com.docker.network.endpoint.sysctls ` , which is where you'll find them in
31+ ` docker inspect ` output. Network drivers may restrict the sysctl settings that can
32+ be modified and, to protect the operation of the network, new restrictions may be
33+ added in the future.
34+
2635## Examples
2736
2837### Connect a running container to a network
@@ -64,6 +73,19 @@ being connected to.
6473``` console
6574$ docker network connect --alias db --alias mysql multi-host-network container2
6675```
76+ ### <a name =" sysctl " ></a > Set a sysctl for a container's interface (--sysctl)
77+
78+ ` --sysctl ` sets a network sysctl on the interface created to connect to the
79+ network, only ` net.ipv4. ` and ` net.ipv6. ` settings can be modified. The
80+ interface name is assigned automatically, so it must be left out along with
81+ the ` net. ` prefix.
82+
83+ If the network interface created in the container is called ` eth3 ` , this
84+ example is equivalent to ` net.ipv4.conf.eth3.log_martians=1 ` .
85+
86+ ``` console
87+ $ docker network connect --sysctl ipv4.conf.log_martians=1 multi-host-network container2
88+ ```
6789
6890### Network implications of stopping, pausing, or restarting containers
6991
0 commit comments