Skip to content

Commit feabf71

Browse files
committed
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>
1 parent 07a7c06 commit feabf71

3 files changed

Lines changed: 220 additions & 151 deletions

File tree

docs/reference/commandline/network_create.md

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,27 @@ parent = "smn_cli"
1010

1111
# network create
1212

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+
```
2934

3035
Creates a new network. The `DRIVER` accepts `bridge` or `overlay` which are the
3136
built-in network drivers. If you have installed a third party or your own custom
@@ -51,7 +56,7 @@ conditions are:
5156
* A cluster of hosts with connectivity to the key-value store.
5257
* A properly configured Engine `daemon` on each host in the cluster.
5358

54-
The `docker daemon` options that support the `overlay` network are:
59+
The `dockerd` options that support the `overlay` network are:
5560

5661
* `--cluster-store`
5762
* `--cluster-store-opt`
@@ -98,36 +103,52 @@ disconnect` command.
98103

99104
## Specifying advanced options
100105

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:
106+
When you create a network, Engine creates a non-overlapping subnetwork for the
107+
network by default. This subnetwork is not a subdivision of an existing
108+
network. It is purely for ip-addressing purposes. You can override this default
109+
and specify subnetwork values directly using the `--subnet` option. On a
110+
`bridge` network you can only create a single subnet:
102111

103112
```bash
104-
docker network create --driver=bridge --subnet=192.168.0.0/16 br0
113+
$ docker network create --driver=bridge --subnet=192.168.0.0/16 br0
105114
```
106-
Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address` options.
115+
116+
Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address`
117+
options.
107118

108119
```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
120+
$ docker network create \
121+
--driver=bridge \
122+
--subnet=172.28.0.0/16 \
123+
--ip-range=172.28.5.0/24 \
124+
--gateway=172.28.5.254 \
125+
br0
110126
```
111127

112128
If you omit the `--gateway` flag the Engine selects one for you from inside a
113129
preferred pool. For `overlay` networks and for network driver plugins that
114130
support it you can create multiple subnetworks.
115131

116132
```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
133+
$ docker network create -d overlay \
134+
--subnet=192.168.0.0/16 \
135+
--subnet=192.170.0.0/16 \
136+
--gateway=192.168.0.100 \
137+
--gateway=192.170.0.100 \
138+
--ip-range=192.168.1.0/24 \
139+
--aux-address a=192.168.1.5 --aux-address b=192.168.1.6 \
140+
--aux-address a=192.170.1.5 --aux-address b=192.170.1.6 \
123141
my-multihost-network
124142
```
125-
Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
143+
144+
Be sure that your subnetworks do not overlap. If they do, the network create
145+
fails and Engine returns an error.
126146

127147
# Bridge driver options
128148

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:
149+
When creating a custom network, the default network driver (i.e. `bridge`) has
150+
additional options that can be passed. The following are those options and the
151+
equivalent docker daemon flags used for docker0 bridge:
131152

132153
| Option | Equivalent | Description |
133154
|--------------------------------------------------|-------------|-------------------------------------------------------|
@@ -137,8 +158,8 @@ The following are those options and the equivalent docker daemon flags used for
137158
| `com.docker.network.bridge.host_binding_ipv4` | `--ip` | Default IP when binding container ports |
138159
| `com.docker.network.mtu` | `--mtu` | Set the containers network MTU |
139160

140-
The following arguments can be passed to `docker network create` for any network driver, again with their approximate
141-
equivalents to `docker daemon`.
161+
The following arguments can be passed to `docker network create` for any
162+
network driver, again with their approximate equivalents to `docker daemon`.
142163

143164
| Argument | Equivalent | Description |
144165
|--------------|----------------|--------------------------------------------|
@@ -148,16 +169,21 @@ equivalents to `docker daemon`.
148169
| `--ipv6` | `--ipv6` | Enable IPv6 networking |
149170
| `--subnet` | `--bip` | Subnet for network |
150171

151-
For example, let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
172+
For example, let's use `-o` or `--opt` options to specify an IP address binding
173+
when publishing ports:
152174

153175
```bash
154-
docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" simple-network
176+
$ docker network create \
177+
-o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" \
178+
simple-network
155179
```
156180

157181
### Network internal mode
158182

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.
183+
By default, when you connect a container to an `overlay` network, Docker also
184+
connects a bridge network to it to provide external connectivity. If you want
185+
to create an externally isolated `overlay` network, you can specify the
186+
`--internal` option.
161187

162188
## Related information
163189

0 commit comments

Comments
 (0)