Browse code

network docs cleanup

This fixes some Markup and formatting
issues in the network documentation;

- wrap text to 80 chars
- add missing language hints for code examples
- add missing line continuations (\)
- update USAGE output for Cobra

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2016/06/06 21:20:41
Showing 3 changed files
... ...
@@ -10,22 +10,27 @@ parent = "smn_cli"
10 10
 
11 11
 # network create
12 12
 
13
-    Usage:  docker network create [OPTIONS] NETWORK-NAME
14
-
15
-    Creates a new network with a name specified by the user
16
-
17
-    --aux-address=map[]      Auxiliary ipv4 or ipv6 addresses used by network driver
18
-    -d --driver=DRIVER       Driver to manage the Network bridge or overlay. The default is bridge.
19
-    --gateway=[]             ipv4 or ipv6 Gateway for the master subnet
20
-    --help                   Print usage
21
-    --internal               Restricts external access to the network
22
-    --ip-range=[]            Allocate container ip from a sub-range
23
-    --ipam-driver=default    IP Address Management Driver
24
-    --ipam-opt=map[]         Set custom IPAM driver specific options
25
-    --ipv6                   Enable IPv6 networking
26
-    --label=[]               Set metadata on a network
27
-    -o --opt=map[]           Set custom driver specific options
28
-    --subnet=[]              Subnet in CIDR format that represents a network segment
13
+```markdown
14
+Usage:	docker network create [OPTIONS]
15
+
16
+Create a network
17
+
18
+Options:
19
+      --aux-address value    auxiliary ipv4 or ipv6 addresses used by Network
20
+                             driver (default map[])
21
+  -d, --driver string        Driver to manage the Network (default "bridge")
22
+      --gateway value        ipv4 or ipv6 Gateway for the master subnet (default [])
23
+      --help                 Print usage
24
+      --internal             restricts external access to the network
25
+      --ip-range value       allocate container ip from a sub-range (default [])
26
+      --ipam-driver string   IP Address Management Driver (default "default")
27
+      --ipam-opt value       set IPAM driver specific options (default map[])
28
+      --ipv6                 enable IPv6 networking
29
+      --label value          Set metadata on a network (default [])
30
+  -o, --opt value            Set driver specific options (default map[])
31
+      --subnet value         subnet in CIDR format that represents a
32
+                             network segment (default [])
33
+```
29 34
 
30 35
 Creates a new network. The `DRIVER` accepts `bridge` or `overlay` which are the
31 36
 built-in network drivers. If you have installed a third party or your own custom
... ...
@@ -51,7 +56,7 @@ conditions are:
51 51
 * A cluster of hosts with connectivity to the key-value store.
52 52
 * A properly configured Engine `daemon` on each host in the cluster.
53 53
 
54
-The `docker daemon` options that support the `overlay` network are:
54
+The `dockerd` options that support the `overlay` network are:
55 55
 
56 56
 * `--cluster-store`
57 57
 * `--cluster-store-opt`
... ...
@@ -98,15 +103,26 @@ disconnect` command.
98 98
 
99 99
 ## Specifying advanced options
100 100
 
101
-When you create a network, Engine creates a non-overlapping subnetwork for the network by default. This subnetwork is not a subdivision of an existing network. It is purely for ip-addressing purposes. You can override this default and specify subnetwork values directly using the `--subnet` option. On a `bridge` network you can only create a single subnet:
101
+When you create a network, Engine creates a non-overlapping subnetwork for the
102
+network by default. This subnetwork is not a subdivision of an existing
103
+network. It is purely for ip-addressing purposes. You can override this default
104
+and specify subnetwork values directly using the `--subnet` option. On a
105
+`bridge` network you can only create a single subnet:
102 106
 
103 107
 ```bash
104
-docker network create --driver=bridge --subnet=192.168.0.0/16 br0
108
+$ docker network create --driver=bridge --subnet=192.168.0.0/16 br0
105 109
 ```
106
-Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address` options.
110
+
111
+Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address`
112
+options.
107 113
 
108 114
 ```bash
109
-network create --driver=bridge --subnet=172.28.0.0/16 --ip-range=172.28.5.0/24 --gateway=172.28.5.254 br0
115
+$ docker network create \
116
+  --driver=bridge \
117
+  --subnet=172.28.0.0/16 \
118
+  --ip-range=172.28.5.0/24 \
119
+  --gateway=172.28.5.254 \
120
+  br0
110 121
 ```
111 122
 
112 123
 If you omit the `--gateway` flag the Engine selects one for you from inside a
... ...
@@ -114,20 +130,25 @@ preferred pool. For `overlay` networks and for network driver plugins that
114 114
 support it you can create multiple subnetworks.
115 115
 
116 116
 ```bash
117
-docker network create -d overlay
118
-  --subnet=192.168.0.0/16 --subnet=192.170.0.0/16
119
-  --gateway=192.168.0.100 --gateway=192.170.0.100
120
-  --ip-range=192.168.1.0/24
121
-  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6
122
-  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6
117
+$ docker network create -d overlay \
118
+  --subnet=192.168.0.0/16 \
119
+  --subnet=192.170.0.0/16 \
120
+  --gateway=192.168.0.100 \ 
121
+  --gateway=192.170.0.100 \
122
+  --ip-range=192.168.1.0/24 \
123
+  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6 \
124
+  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6 \
123 125
   my-multihost-network
124 126
 ```
125
-Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
127
+
128
+Be sure that your subnetworks do not overlap. If they do, the network create
129
+fails and Engine returns an error.
126 130
 
127 131
 # Bridge driver options
128 132
 
129
-When creating a custom network, the default network driver (i.e. `bridge`) has additional options that can be passed.
130
-The following are those options and the equivalent docker daemon flags used for docker0 bridge:
133
+When creating a custom network, the default network driver (i.e. `bridge`) has
134
+additional options that can be passed. The following are those options and the
135
+equivalent docker daemon flags used for docker0 bridge:
131 136
 
132 137
 | Option                                           | Equivalent  | Description                                           |
133 138
 |--------------------------------------------------|-------------|-------------------------------------------------------|
... ...
@@ -137,8 +158,8 @@ The following are those options and the equivalent docker daemon flags used for
137 137
 | `com.docker.network.bridge.host_binding_ipv4`    | `--ip`      | Default IP when binding container ports               |
138 138
 | `com.docker.network.mtu`                         | `--mtu`     | Set the containers network MTU                        |
139 139
 
140
-The following arguments can be passed to `docker network create` for any network driver, again with their approximate
141
-equivalents to `docker daemon`.
140
+The following arguments can be passed to `docker network create` for any
141
+network driver, again with their approximate equivalents to `docker daemon`.
142 142
 
143 143
 | Argument     | Equivalent     | Description                                |
144 144
 |--------------|----------------|--------------------------------------------|
... ...
@@ -148,16 +169,21 @@ equivalents to `docker daemon`.
148 148
 | `--ipv6`     | `--ipv6`       | Enable IPv6 networking                     |
149 149
 | `--subnet`   | `--bip`        | Subnet for network                         |
150 150
 
151
-For example, let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
151
+For example, let's use `-o` or `--opt` options to specify an IP address binding
152
+when publishing ports:
152 153
 
153 154
 ```bash
154
-docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" simple-network
155
+$ docker network create \
156
+    -o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" \
157
+    simple-network
155 158
 ```
156 159
 
157 160
 ### Network internal mode
158 161
 
159
-By default, when you connect a container to an `overlay` network, Docker also connects a bridge network to it to provide external connectivity.
160
-If you want to create an externally isolated `overlay` network, you can specify the `--internal` option.
162
+By default, when you connect a container to an `overlay` network, Docker also
163
+connects a bridge network to it to provide external connectivity. If you want
164
+to create an externally isolated `overlay` network, you can specify the
165
+`--internal` option.
161 166
 
162 167
 ## Related information
163 168
 
... ...
@@ -11,7 +11,9 @@ weight=-4
11 11
 
12 12
 # Work with network commands
13 13
 
14
-This article provides examples of the network subcommands you can use to interact with Docker networks and the containers in them. The commands are available through the Docker Engine CLI.  These commands are:
14
+This article provides examples of the network subcommands you can use to
15
+interact with Docker networks and the containers in them. The commands are
16
+available through the Docker Engine CLI. These commands are:
15 17
 
16 18
 * `docker network create`
17 19
 * `docker network connect`
... ...
@@ -30,9 +32,13 @@ the [Getting started with multi-host networks](get-started-overlay.md) instead.
30 30
 
31 31
 Docker Engine creates a `bridge` network automatically when you install Engine.
32 32
 This network corresponds to the `docker0` bridge that Engine has traditionally
33
-relied on. In addition to this network, you can create your own `bridge` or `overlay` network.  
33
+relied on. In addition to this network, you can create your own `bridge` or
34
+`overlay` network.
34 35
 
35
-A `bridge` network resides on a single host running an instance of Docker Engine.  An `overlay` network can span multiple hosts running their own engines. If you run `docker network create` and supply only a network name, it creates a bridge network for you.
36
+A `bridge` network resides on a single host running an instance of Docker
37
+Engine. An `overlay` network can span multiple hosts running their own engines.
38
+If you run `docker network create` and supply only a network name, it creates a
39
+bridge network for you.
36 40
 
37 41
 ```bash
38 42
 $ docker network create simple-network
... ...
@@ -87,22 +93,27 @@ specify a single subnet. An `overlay` network supports multiple subnets.
87 87
 > in your infrastructure that is not managed by docker. Such overlaps can cause
88 88
 > connectivity issues or failures when containers are connected to that network.
89 89
 
90
-In addition to the `--subnet` option, you also specify the `--gateway` `--ip-range` and `--aux-address` options.
90
+In addition to the `--subnet` option, you also specify the `--gateway`,
91
+`--ip-range`, and `--aux-address` options.
91 92
 
92 93
 ```bash
93
-$ docker network create -d overlay
94
-  --subnet=192.168.0.0/16 --subnet=192.170.0.0/16
95
-  --gateway=192.168.0.100 --gateway=192.170.0.100
96
-  --ip-range=192.168.1.0/24
97
-  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6
98
-  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6
94
+$ docker network create -d overlay \
95
+  --subnet=192.168.0.0/16 \
96
+  --subnet=192.170.0.0/16 \
97
+  --gateway=192.168.0.100 \
98
+  --gateway=192.170.0.100 \
99
+  --ip-range=192.168.1.0/24 \
100
+  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6 \
101
+  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6 \
99 102
   my-multihost-network
100 103
 ```
101 104
 
102
-Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
105
+Be sure that your subnetworks do not overlap. If they do, the network create
106
+fails and Engine returns an error.
103 107
 
104
-When creating a custom network, the default network driver (i.e. `bridge`) has additional options that can be passed.
105
-The following are those options and the equivalent docker daemon flags used for docker0 bridge:
108
+When creating a custom network, the default network driver (i.e. `bridge`) has
109
+additional options that can be passed. The following are those options and the
110
+equivalent docker daemon flags used for docker0 bridge:
106 111
 
107 112
 | Option                                           | Equivalent  | Description                                           |
108 113
 |--------------------------------------------------|-------------|-------------------------------------------------------|
... ...
@@ -181,7 +192,8 @@ $ docker network create -d bridge --subnet 172.25.0.0/16 isolated_nw
181 181
 06a62f1c73c4e3107c0f555b7a5f163309827bfbbf999840166065a8f35455a8
182 182
 ```
183 183
 
184
-Connect `container2` to the network and then `inspect` the network to verify the connection:
184
+Connect `container2` to the network and then `inspect` the network to verify
185
+the connection:
185 186
 
186 187
 ```
187 188
 $ docker network connect isolated_nw container2
... ...
@@ -225,14 +237,15 @@ $ docker run --net=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox
225 225
 467a7863c3f0277ef8e661b38427737f28099b61fa55622d6c30fb288d88c551
226 226
 ```
227 227
 
228
-As you can see you were able to specify the ip address for your container.
229
-As long as the network to which the container is connecting was created with
230
-a user specified subnet, you will be able to select the IPv4 and/or IPv6 address(es)
231
-for your container when executing `docker run` and `docker network connect` commands
232
-by respectively passing the `--ip` and `--ip6` flags for IPv4 and IPv6.
233
-The selected IP address is part of the container networking configuration and will be
234
-preserved across container reload. The feature is only available on user defined networks,
235
-because they guarantee their subnets configuration does not change across daemon reload.
228
+As you can see you were able to specify the ip address for your container. As
229
+long as the network to which the container is connecting was created with a
230
+user specified subnet, you will be able to select the IPv4 and/or IPv6
231
+address(es) for your container when executing `docker run` and `docker network
232
+connect` commands by respectively passing the `--ip` and `--ip6` flags for IPv4
233
+and IPv6. The selected IP address is part of the container networking
234
+configuration and will be preserved across container reload. The feature is
235
+only available on user defined networks, because they guarantee their subnets
236
+configuration does not change across daemon reload.
236 237
 
237 238
 Now, inspect the network resources used by `container3`.
238 239
 
... ...
@@ -289,7 +302,9 @@ examine its networking stack:
289 289
 $ docker attach container2
290 290
 ```
291 291
 
292
-If you look at the container's network stack you should see two Ethernet interfaces, one for the default bridge network and one for the `isolated_nw` network.
292
+If you look at the container's network stack you should see two Ethernet
293
+interfaces, one for the default bridge network and one for the `isolated_nw`
294
+network.
293 295
 
294 296
 ```bash
295 297
 / # ifconfig
... ...
@@ -321,7 +336,9 @@ lo        Link encap:Local Loopback
321 321
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
322 322
 ```
323 323
 
324
-On the `isolated_nw` which was user defined, the Docker embedded DNS server enables name resolution for other containers in the network.  Inside of `container2` it is possible to ping `container3` by name.
324
+On the `isolated_nw` which was user defined, the Docker embedded DNS server
325
+enables name resolution for other containers in the network. Inside of
326
+`container2` it is possible to ping `container3` by name.
325 327
 
326 328
 ```bash
327 329
 / # ping -w 4 container3
... ...
@@ -336,7 +353,10 @@ PING container3 (172.25.3.3): 56 data bytes
336 336
 round-trip min/avg/max = 0.070/0.081/0.097 ms
337 337
 ```
338 338
 
339
-This isn't the case for the default `bridge` network. Both `container2` and  `container1` are connected to the default bridge network. Docker does not support automatic service discovery on this network. For this reason, pinging  `container1` by name fails as you would expect based on the `/etc/hosts` file:
339
+This isn't the case for the default `bridge` network. Both `container2` and
340
+`container1` are connected to the default bridge network. Docker does not
341
+support automatic service discovery on this network. For this reason, pinging
342
+`container1` by name fails as you would expect based on the `/etc/hosts` file:
340 343
 
341 344
 ```bash
342 345
 / # ping -w 4 container1
... ...
@@ -384,56 +404,61 @@ You can connect both running and non-running containers to a network. However,
384 384
 
385 385
 ### Linking containers in user-defined networks
386 386
 
387
-In the above example, `container2` was able to resolve `container3`'s name automatically
388
-in the user defined network `isolated_nw`, but the name resolution did not succeed
389
-automatically in the default `bridge` network. This is expected in order to maintain
390
-backward compatibility with [legacy link](default_network/dockerlinks.md).
387
+In the above example, `container2` was able to resolve `container3`'s name
388
+automatically in the user defined network `isolated_nw`, but the name
389
+resolution did not succeed automatically in the default `bridge` network. This
390
+is expected in order to maintain backward compatibility with [legacy
391
+link](default_network/dockerlinks.md).
391 392
 
392
-The `legacy link` provided 4 major functionalities to the default `bridge` network.
393
+The `legacy link` provided 4 major functionalities to the default `bridge`
394
+network.
393 395
 
394 396
 * name resolution
395 397
 * name alias for the linked container using `--link=CONTAINER-NAME:ALIAS`
396 398
 * secured container connectivity (in isolation via `--icc=false`)
397 399
 * environment variable injection
398 400
 
399
-Comparing the above 4 functionalities with the non-default user-defined networks such as
400
-`isolated_nw` in this example, without any additional config, `docker network` provides
401
+Comparing the above 4 functionalities with the non-default user-defined
402
+networks such as `isolated_nw` in this example, without any additional config,
403
+`docker network` provides
401 404
 
402 405
 * automatic name resolution using DNS
403 406
 * automatic secured isolated environment for the containers in a network
404 407
 * ability to dynamically attach and detach to multiple networks
405 408
 * supports the `--link` option to provide name alias for the linked container
406 409
 
407
-Continuing with the above example, create another container `container4` in `isolated_nw`
408
-with `--link` to provide additional name resolution using alias for other containers in
409
-the same network.
410
+Continuing with the above example, create another container `container4` in
411
+`isolated_nw` with `--link` to provide additional name resolution using alias
412
+for other containers in the same network.
410 413
 
411 414
 ```bash
412 415
 $ docker run --net=isolated_nw -itd --name=container4 --link container5:c5 busybox
413 416
 01b5df970834b77a9eadbaff39051f237957bd35c4c56f11193e0594cfd5117c
414 417
 ```
415 418
 
416
-With the help of `--link` `container4` will be able to reach `container5` using the
417
-aliased name `c5` as well.
419
+With the help of `--link` `container4` will be able to reach `container5` using
420
+the aliased name `c5` as well.
418 421
 
419
-Please note that while creating `container4`, we linked to a container named `container5`
420
-which is not created yet. That is one of the differences in behavior between the
421
-*legacy link* in default `bridge` network and the new *link* functionality in user defined
422
-networks. The *legacy link* is static in nature and it hard-binds the container with the
423
-alias and it doesn't tolerate linked container restarts. While the new *link* functionality
424
-in user defined networks are dynamic in nature and supports linked container restarts
425
-including tolerating ip-address changes on the linked container.
422
+Please note that while creating `container4`, we linked to a container named
423
+`container5` which is not created yet. That is one of the differences in
424
+behavior between the *legacy link* in default `bridge` network and the new
425
+*link* functionality in user defined networks. The *legacy link* is static in
426
+nature and it hard-binds the container with the alias and it doesn't tolerate
427
+linked container restarts. While the new *link* functionality in user defined
428
+networks are dynamic in nature and supports linked container restarts including
429
+tolerating ip-address changes on the linked container.
426 430
 
427
-Now let us launch another container named `container5` linking `container4` to c4.
431
+Now let us launch another container named `container5` linking `container4` to
432
+c4.
428 433
 
429 434
 ```bash
430 435
 $ docker run --net=isolated_nw -itd --name=container5 --link container4:c4 busybox
431 436
 72eccf2208336f31e9e33ba327734125af00d1e1d2657878e2ee8154fbb23c7a
432 437
 ```
433 438
 
434
-As expected, `container4` will be able to reach `container5` by both its container name and
435
-its alias c5 and `container5` will be able to reach `container4` by its container name and
436
-its alias c4.
439
+As expected, `container4` will be able to reach `container5` by both its
440
+container name and its alias c5 and `container5` will be able to reach
441
+`container4` by its container name and its alias c4.
437 442
 
438 443
 ```bash
439 444
 $ docker attach container4
... ...
@@ -485,12 +510,13 @@ PING container4 (172.25.0.4): 56 data bytes
485 485
 round-trip min/avg/max = 0.065/0.070/0.082 ms
486 486
 ```
487 487
 
488
-Similar to the legacy link functionality the new link alias is localized to a container
489
-and the aliased name has no meaning outside of the container using the `--link`.
488
+Similar to the legacy link functionality the new link alias is localized to a
489
+container and the aliased name has no meaning outside of the container using
490
+the `--link`.
490 491
 
491
-Also, it is important to note that if a container belongs to multiple networks, the
492
-linked alias is scoped within a given network. Hence the containers can be linked to
493
-different aliases in different networks.
492
+Also, it is important to note that if a container belongs to multiple networks,
493
+the linked alias is scoped within a given network. Hence the containers can be
494
+linked to different aliases in different networks.
494 495
 
495 496
 Extending the example, let us create another network named `local_alias`
496 497
 
... ...
@@ -532,8 +558,8 @@ PING c5 (172.25.0.5): 56 data bytes
532 532
 round-trip min/avg/max = 0.070/0.081/0.097 ms
533 533
 ```
534 534
 
535
-Note that the ping succeeds for both the aliases but on different networks.
536
-Let us conclude this section by disconnecting `container5` from the `isolated_nw`
535
+Note that the ping succeeds for both the aliases but on different networks. Let
536
+us conclude this section by disconnecting `container5` from the `isolated_nw`
537 537
 and observe the results
538 538
 
539 539
 ```
... ...
@@ -557,27 +583,28 @@ round-trip min/avg/max = 0.070/0.081/0.097 ms
557 557
 
558 558
 ```
559 559
 
560
-In conclusion, the new link functionality in user defined networks provides all the
561
-benefits of legacy links while avoiding most of the well-known issues with *legacy links*.
560
+In conclusion, the new link functionality in user defined networks provides all
561
+the benefits of legacy links while avoiding most of the well-known issues with
562
+*legacy links*.
562 563
 
563
-One notable missing functionality compared to *legacy links* is the injection of
564
-environment variables. Though very useful, environment variable injection is static
565
-in nature and must be injected when the container is started. One cannot inject
566
-environment variables into a running container without significant effort and hence
567
-it is not compatible with `docker network` which provides a dynamic way to connect/
568
-disconnect containers to/from a network.
564
+One notable missing functionality compared to *legacy links* is the injection
565
+of environment variables. Though very useful, environment variable injection is
566
+static in nature and must be injected when the container is started. One cannot
567
+inject environment variables into a running container without significant
568
+effort and hence it is not compatible with `docker network` which provides a
569
+dynamic way to connect/ disconnect containers to/from a network.
569 570
 
570 571
 ### Network-scoped alias
571 572
 
572
-While *link*s provide private name resolution that is localized within a container,
573
-the network-scoped alias provides a way for a container to be discovered by an
574
-alternate name by any other container within the scope of a particular network.
575
-Unlike the *link* alias, which is defined by the consumer of a service, the
576
-network-scoped alias is defined by the container that is offering the service
577
-to the network.
573
+While *link*s provide private name resolution that is localized within a
574
+container, the network-scoped alias provides a way for a container to be
575
+discovered by an alternate name by any other container within the scope of a
576
+particular network. Unlike the *link* alias, which is defined by the consumer
577
+of a service, the network-scoped alias is defined by the container that is
578
+offering the service to the network.
578 579
 
579
-Continuing with the above example, create another container in `isolated_nw` with a
580
-network alias.
580
+Continuing with the above example, create another container in `isolated_nw`
581
+with a network alias.
581 582
 
582 583
 ```bash
583 584
 $ docker run --net=isolated_nw -itd --name=container6 --net-alias app busybox
... ...
@@ -609,18 +636,18 @@ PING container5 (172.25.0.6): 56 data bytes
609 609
 round-trip min/avg/max = 0.070/0.081/0.097 ms
610 610
 ```
611 611
 
612
-Now let us connect `container6` to the `local_alias` network with a different network-scoped
613
-alias.
612
+Now let us connect `container6` to the `local_alias` network with a different
613
+network-scoped alias.
614 614
 
615
-```
615
+```bash
616 616
 $ docker network connect --alias scoped-app local_alias container6
617 617
 ```
618 618
 
619
-`container6` in this example now is aliased as `app` in network `isolated_nw` and
620
-as `scoped-app` in network `local_alias`.
619
+`container6` in this example now is aliased as `app` in network `isolated_nw`
620
+and as `scoped-app` in network `local_alias`.
621 621
 
622
-Let's try to reach these aliases from `container4` (which is connected to both these networks)
623
-and `container5` (which is connected only to `isolated_nw`).
622
+Let's try to reach these aliases from `container4` (which is connected to both
623
+these networks) and `container5` (which is connected only to `isolated_nw`).
624 624
 
625 625
 ```bash
626 626
 $ docker attach container4
... ...
@@ -643,25 +670,25 @@ ping: bad address 'scoped-app'
643 643
 
644 644
 ```
645 645
 
646
-As you can see, the alias is scoped to the network it is defined on and hence only
647
-those containers that are connected to that network can access the alias.
646
+As you can see, the alias is scoped to the network it is defined on and hence
647
+only those containers that are connected to that network can access the alias.
648 648
 
649
-In addition to the above features, multiple containers can share the same network-scoped
650
-alias within the same network. For example, let's launch `container7` in `isolated_nw` with
651
-the same alias as `container6`
649
+In addition to the above features, multiple containers can share the same
650
+network-scoped alias within the same network. For example, let's launch
651
+`container7` in `isolated_nw` with the same alias as `container6`
652 652
 
653 653
 ```bash
654 654
 $ docker run --net=isolated_nw -itd --name=container7 --net-alias app busybox
655 655
 3138c678c123b8799f4c7cc6a0cecc595acbdfa8bf81f621834103cd4f504554
656 656
 ```
657 657
 
658
-When multiple containers share the same alias, name resolution to that alias will happen
659
-to one of the containers (typically the first container that is aliased). When the container
660
-that backs the alias goes down or disconnected from the network, the next container that
661
-backs the alias will be resolved.
658
+When multiple containers share the same alias, name resolution to that alias
659
+will happen to one of the containers (typically the first container that is
660
+aliased). When the container that backs the alias goes down or disconnected
661
+from the network, the next container that backs the alias will be resolved.
662 662
 
663
-Let us ping the alias `app` from `container4` and bring down `container6` to verify that
664
-`container7` is resolving the `app` alias.
663
+Let us ping the alias `app` from `container4` and bring down `container6` to
664
+verify that `container7` is resolving the `app` alias.
665 665
 
666 666
 ```bash
667 667
 $ docker attach container4
... ...
@@ -697,10 +724,10 @@ round-trip min/avg/max = 0.072/0.085/0.101 ms
697 697
 You can disconnect a container from a network using the `docker network
698 698
 disconnect` command.
699 699
 
700
-```
700
+```bash
701 701
 $ docker network disconnect isolated_nw container2
702 702
 
703
-docker inspect --format='{{json .NetworkSettings.Networks}}'  container2 | python -m json.tool
703
+$ docker inspect --format='{{json .NetworkSettings.Networks}}'  container2 | python -m json.tool
704 704
 {
705 705
     "bridge": {
706 706
         "NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
... ...
@@ -747,9 +774,10 @@ $ docker network inspect isolated_nw
747 747
 ```
748 748
 
749 749
 Once a container is disconnected from a network, it cannot communicate with
750
-other containers connected to that network. In this example, `container2` can no longer  talk to `container3` on the `isolated_nw` network.
750
+other containers connected to that network. In this example, `container2` can
751
+no longer talk to `container3` on the `isolated_nw` network.
751 752
 
752
-```
753
+```bash
753 754
 $ docker attach container2
754 755
 
755 756
 / # ifconfig
... ...
@@ -792,15 +820,16 @@ round-trip min/avg/max = 0.119/0.146/0.174 ms
792 792
 / #
793 793
 ```
794 794
 
795
-There are certain scenarios such as ungraceful docker daemon restarts in multi-host network,
796
-where the daemon is unable to cleanup stale connectivity endpoints. Such stale endpoints
797
-may cause an error `container already connected to network` when a new container is
798
-connected to that network with the same name as the stale endpoint. In order to cleanup
799
-these stale endpoints, first remove the container and force disconnect 
800
-(`docker network disconnect -f`)  the endpoint from the network. Once the endpoint is 
801
-cleaned up, the container can be connected to the network.
795
+There are certain scenarios such as ungraceful docker daemon restarts in
796
+multi-host network, where the daemon is unable to cleanup stale connectivity
797
+endpoints. Such stale endpoints may cause an error `container already connected
798
+to network` when a new container is connected to that network with the same
799
+name as the stale endpoint. In order to cleanup these stale endpoints, first
800
+remove the container and force disconnect (`docker network disconnect -f`) the
801
+endpoint from the network. Once the endpoint is cleaned up, the container can
802
+be connected to the network.
802 803
 
803
-```
804
+```bash
804 805
 $ docker run -d --name redis_db --net multihost redis
805 806
 ERROR: Cannot start container bc0b19c089978f7845633027aa3435624ca3d12dd4f4f764b61eac4c0610f32e: container already connected to network multihost
806 807
 
... ...
@@ -813,7 +842,8 @@ $ docker run -d --name redis_db --net multihost redis
813 813
 
814 814
 ## Remove a network
815 815
 
816
-When all the containers in a network are stopped or disconnected, you can remove a network.
816
+When all the containers in a network are stopped or disconnected, you can
817
+remove a network.
817 818
 
818 819
 ```bash
819 820
 $ docker network disconnect isolated_nw container3
... ...
@@ -846,7 +876,7 @@ $ docker network rm isolated_nw
846 846
 
847 847
 List all your networks to verify the `isolated_nw` was removed:
848 848
 
849
-```
849
+```bash
850 850
 $ docker network ls
851 851
 NETWORK ID          NAME                DRIVER
852 852
 72314fa53006        host                host                
... ...
@@ -101,12 +101,19 @@ specify subnetwork values directly using the `--subnet` option. On a
101 101
 `bridge` network you can only create a single subnet:
102 102
 
103 103
 ```bash
104
-docker network create -d bridge --subnet=192.168.0.0/16 br0
104
+$ docker network create -d bridge --subnet=192.168.0.0/16 br0
105 105
 ```
106
-Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address` options.
106
+
107
+Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address`
108
+options.
107 109
 
108 110
 ```bash
109
-network create --driver=bridge --subnet=172.28.0.0/16 --ip-range=172.28.5.0/24 --gateway=172.28.5.254 br0
111
+$ docker network create \
112
+  --driver=bridge \
113
+  --subnet=172.28.0.0/16 \
114
+  --ip-range=172.28.5.0/24 \
115
+  --gateway=172.28.5.254 \
116
+  br0
110 117
 ```
111 118
 
112 119
 If you omit the `--gateway` flag the Engine selects one for you from inside a
... ...
@@ -114,20 +121,26 @@ preferred pool. For `overlay` networks and for network driver plugins that
114 114
 support it you can create multiple subnetworks.
115 115
 
116 116
 ```bash
117
-docker network create -d overlay
118
-  --subnet=192.168.0.0/16 --subnet=192.170.0.0/16
119
-  --gateway=192.168.0.100 --gateway=192.170.0.100
120
-  --ip-range=192.168.1.0/24
121
-  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6
122
-  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6
117
+$ docker network create -d overlay \
118
+  --subnet=192.168.0.0/16 \
119
+  --subnet=192.170.0.0/16 \
120
+  --gateway=192.168.0.100 \ 
121
+  --gateway=192.170.0.100 \
122
+  --ip-range=192.168.1.0/24 \
123
+  --aux-address a=192.168.1.5 --aux-address b=192.168.1.6 \
124
+  --aux-address a=192.170.1.5 --aux-address b=192.170.1.6 \
123 125
   my-multihost-network
124 126
 ```
125
-Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
127
+
128
+Be sure that your subnetworks do not overlap. If they do, the network create
129
+fails and Engine returns an error.
126 130
 
127 131
 ### Network internal mode
128 132
 
129
-By default, when you connect a container to an `overlay` network, Docker also connects a bridge network to it to provide external connectivity.
130
-If you want to create an externally isolated `overlay` network, you can specify the `--internal` option.
133
+By default, when you connect a container to an `overlay` network, Docker also
134
+connects a bridge network to it to provide external connectivity. If you want
135
+to create an externally isolated `overlay` network, you can specify the
136
+`--internal` option.
131 137
 
132 138
 # OPTIONS
133 139
 **--aux-address**=map[]