Browse code

docs: document options for default network driver

Fixes issue #18410

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>

Wen Cheng Ma authored on 2016/01/18 14:02:10
Showing 4 changed files
... ...
@@ -21,8 +21,8 @@ parent = "smn_cli"
21 21
     --internal               Restricts external access to the network
22 22
     --ip-range=[]            Allocate container ip from a sub-range
23 23
     --ipam-driver=default    IP Address Management Driver
24
-    -o --opt=map[]           Set custom network plugin options
25
-    --ipam-opt=map[]         Set custom IPAM plugin options
24
+    --ipam-opt=map[]         Set custom IPAM driver specific options
25
+    -o --opt=map[]           Set custom driver specific options
26 26
     --subnet=[]              Subnet in CIDR format that represents a network segment
27 27
 
28 28
 Creates a new network. The `DRIVER` accepts `bridge` or `overlay` which are the
... ...
@@ -122,6 +122,26 @@ docker network create -d overlay
122 122
 ```
123 123
 Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
124 124
 
125
+# Bridge driver options
126
+
127
+When creating a custom network, the default network driver (i.e. `bridge`) has additional options that can be passed.
128
+The following are those options and the equivalent docker daemon flags used for docker0 bridge:
129
+
130
+| Option                                           | Equivalent  | Description                                           |
131
+|--------------------------------------------------|-------------|-------------------------------------------------------|
132
+| `com.docker.network.bridge.name`                 | -           | bridge name to be used when creating the Linux bridge |
133
+| `com.docker.network.bridge.enable_ip_masquerade` | `--ip-masq` | Enable IP masquerading                                |
134
+| `com.docker.network.bridge.enable_icc`           | `--icc`     | Enable or Disable Inter Container Connectivity        |
135
+| `com.docker.network.bridge.host_binding_ipv4`    | `--ip`      | Default IP when binding container ports               |
136
+| `com.docker.network.mtu`                         | `--mtu`     | Set the containers network MTU                        |
137
+| `com.docker.network.enable_ipv6`                 | `--ipv6`    | Enable IPv6 networking                                |
138
+
139
+For example, let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
140
+
141
+```bash
142
+docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" simple-network
143
+```
144
+
125 145
 ### Network internal mode
126 146
 
127 147
 By default, when you connect a container to an `overlay` network, Docker also connects a bridge network to it to provide external connectivity.
... ...
@@ -168,7 +168,10 @@ If you inspect the network, you'll find that it has nothing in it.
168 168
             "IPAM": {
169 169
                 "Driver": "default",
170 170
                 "Config": [
171
-                    {}
171
+                    {
172
+                        "Subnet": "172.18.0.0/16",
173
+                        "Gateway": "172.18.0.1/16"
174
+                    }
172 175
                 ]
173 176
             },
174 177
             "Containers": {},
... ...
@@ -95,6 +95,53 @@ $ docker network create -d overlay
95 95
 
96 96
 Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
97 97
 
98
+When creating a custom network, the default network driver (i.e. `bridge`) has additional options that can be passed.
99
+The following are those options and the equivalent docker daemon flags used for docker0 bridge:
100
+
101
+| Option                                           | Equivalent  | Description                                           |
102
+|--------------------------------------------------|-------------|-------------------------------------------------------|
103
+| `com.docker.network.bridge.name`                 | -           | bridge name to be used when creating the Linux bridge |
104
+| `com.docker.network.bridge.enable_ip_masquerade` | `--ip-masq` | Enable IP masquerading                                |
105
+| `com.docker.network.bridge.enable_icc`           | `--icc`     | Enable or Disable Inter Container Connectivity        |
106
+| `com.docker.network.bridge.host_binding_ipv4`    | `--ip`      | Default IP when binding container ports               |
107
+| `com.docker.network.mtu`                         | `--mtu`     | Set the containers network MTU                        |
108
+| `com.docker.network.enable_ipv6`                 | `--ipv6`    | Enable IPv6 networking                                |
109
+
110
+For example, now let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
111
+
112
+```bash
113
+$ docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.23.0.1" my-network
114
+b1a086897963e6a2e7fc6868962e55e746bee8ad0c97b54a5831054b5f62672a
115
+$ docker network inspect my-network
116
+[
117
+    {
118
+        "Name": "my-network",
119
+        "Id": "b1a086897963e6a2e7fc6868962e55e746bee8ad0c97b54a5831054b5f62672a",
120
+        "Scope": "local",
121
+        "Driver": "bridge",
122
+        "IPAM": {
123
+            "Driver": "default",
124
+            "Options": {},
125
+            "Config": [
126
+                {
127
+                    "Subnet": "172.23.0.0/16",
128
+                    "Gateway": "172.23.0.1/16"
129
+                }
130
+            ]
131
+        },
132
+        "Containers": {},
133
+        "Options": {
134
+            "com.docker.network.bridge.host_binding_ipv4": "172.23.0.1"
135
+        }
136
+    }
137
+]
138
+$ docker run -d -P --name redis --net my-network redis
139
+bafb0c808c53104b2c90346f284bda33a69beadcab4fc83ab8f2c5a4410cd129
140
+$ docker ps
141
+CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                        NAMES
142
+bafb0c808c53        redis               "/entrypoint.sh redis"   4 seconds ago       Up 3 seconds        172.23.0.1:32770->6379/tcp   redis
143
+```
144
+
98 145
 ## Connect containers
99 146
 
100 147
 You can connect containers dynamically to one or more networks. These networks
... ...
@@ -150,10 +150,10 @@ If you want to create an externally isolated `overlay` network, you can specify
150 150
   IP Address Management Driver
151 151
 
152 152
 **--ipam-opt**=map[]
153
-  Set custom IPAM plugin options
153
+  Set custom IPAM driver options
154 154
 
155 155
 **-o**, **--opt**=map[]
156
-  Set custom network plugin options
156
+  Set custom driver options
157 157
 
158 158
 **--subnet**=[]
159 159
   Subnet in CIDR format that represents a network segment