Browse code

Add missing documentation for static IP options

Signed-off-by: Alessandro Boch <aboch@docker.com>

Alessandro Boch authored on 2016/01/12 11:03:40
Showing 8 changed files
... ...
@@ -3032,7 +3032,7 @@ Content-Type: application/json
3032 3032
 
3033 3033
 {
3034 3034
   "Container":"3613f73ba0e4",
3035
-  "endpoint_config": {
3035
+  "EndpointConfig": {
3036 3036
     "test_nw": {
3037 3037
         "IPv4Address":"172.24.56.89",
3038 3038
         "IPv6Address":"2001:db8::5689"
... ...
@@ -46,6 +46,8 @@ Creates a new container.
46 46
       -h, --hostname=""             Container host name
47 47
       --help                        Print usage
48 48
       -i, --interactive             Keep STDIN open even if not attached
49
+      --ip=""                       Container IPv4 address (e.g. 172.30.100.104)
50
+      --ip6=""                      Container IPv6 address (e.g. 2001:db8::33)
49 51
       --ipc=""                      IPC namespace to use
50 52
       --isolation=""                Container isolation technology
51 53
       --kernel-memory=""            Kernel memory limit
... ...
@@ -15,7 +15,7 @@ parent = "smn_cli"
15 15
     Connects a container to a network
16 16
 
17 17
       --help             Print usage
18
-      --ip               IP Address
18
+      --ip               IPv4 Address
19 19
       --ip6              IPv6 Address
20 20
       --link=[]          Add a link to another container
21 21
 
... ...
@@ -46,11 +46,22 @@ $ docker network connect --link container1:c1 multi-host-network container2
46 46
 ```
47 47
 
48 48
 You can pause, restart, and stop containers that are connected to a network.
49
-Paused containers remain connected and a revealed by a `network inspect`. When
50
-the container is stopped, it does not appear on the network until you restart
51
-it. The container's IP address is not guaranteed to remain the same when a
52
-stopped container rejoins the network, unless you specified one when you run
53
-`docker network connect` command.
49
+Paused containers remain connected and can be revealed by a `network inspect`.
50
+When the container is stopped, it does not appear on the network until you restart
51
+it. If specified, the container's IP address(es) will be reapplied (if still available)
52
+when a stopped container rejoins the network. One way to guarantee that the container
53
+will be assigned the same IP addresses when it rejoins the network after a stop
54
+or a disconnect, is to specify the `--ip-range` when creating the network, and choose
55
+the static IP address(es) from outside the range. This will ensure that the IP address
56
+will not be given to other dynamic containers while this container is not on the network.
57
+
58
+```bash
59
+$ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network
60
+```
61
+
62
+```bash
63
+$ docker network connect --ip 172.20.128.2 multi-host-network container2
64
+```
54 65
 
55 66
 To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network.
56 67
 
... ...
@@ -46,6 +46,8 @@ parent = "smn_cli"
46 46
       -h, --hostname=""             Container host name
47 47
       --help                        Print usage
48 48
       -i, --interactive             Keep STDIN open even if not attached
49
+      --ip=""                       Container IPv4 address (e.g. 172.30.100.104)
50
+      --ip6=""                      Container IPv6 address (e.g. 2001:db8::33)
49 51
       --ipc=""                      IPC namespace to use
50 52
       --isolation=""                Container isolation technology
51 53
       --kernel-memory=""            Kernel memory limit
... ...
@@ -56,8 +58,6 @@ parent = "smn_cli"
56 56
       --log-opt=[]                  Log driver specific options
57 57
       -m, --memory=""               Memory limit
58 58
       --mac-address=""              Container MAC address (e.g. 92:d0:c6:0a:29:33)
59
-      --ip=""                       Container IPv4 address (e.g. 172.30.100.104)
60
-      --ip6=""                      Container IPv6 address (e.g. 2001:db8::33)
61 59
       --memory-reservation=""       Memory soft limit
62 60
       --memory-swap=""              A positive integer equal to memory plus swap. Specify -1 to enable unlimited swap.
63 61
       --memory-swappiness=""        Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
... ...
@@ -330,6 +330,13 @@ This adds the `busybox` container to the `mynet` network.
330 330
 $ docker run -itd --net=my-multihost-network busybox
331 331
 ```
332 332
 
333
+You can also choose the IP addresses for the container with `--ip` and `--ip6`
334
+flags when you start the container on a user-defined network.
335
+
336
+```bash
337
+$ docker run -itd --net=my-multihost-network --ip=10.10.9.75 busybox
338
+```
339
+
333 340
 If you want to add a running container to a network use the `docker network connect` subcommand.
334 341
 
335 342
 You can connect multiple containers to the same network. Once connected, the
... ...
@@ -276,7 +276,7 @@ of the containers.
276 276
     --add-host=""    : Add a line to /etc/hosts (host:IP)
277 277
     --mac-address="" : Sets the container's Ethernet device's MAC address
278 278
     --ip=""          : Sets the container's Ethernet device's IPv4 address
279
-    --ip6=""          : Sets the container's Ethernet device's IPv6 address
279
+    --ip6=""         : Sets the container's Ethernet device's IPv6 address
280 280
 
281 281
 By default, all containers have networking enabled and they can make any
282 282
 outgoing connections. The operator can completely disable networking
... ...
@@ -35,6 +35,8 @@ docker-create - Create a new container
35 35
 [**-h**|**--hostname**[=*HOSTNAME*]]
36 36
 [**--help**]
37 37
 [**-i**|**--interactive**]
38
+[**--ip**[=*IPv4-ADDRESS*]]
39
+[**--ip6**[=*IPv6-ADDRESS*]]
38 40
 [**--ipc**[=*IPC*]]
39 41
 [**--isolation**[=*default*]]
40 42
 [**--kernel-memory**[=*KERNEL-MEMORY*]]
... ...
@@ -174,6 +176,16 @@ two memory nodes.
174 174
 **-i**, **--interactive**=*true*|*false*
175 175
    Keep STDIN open even if not attached. The default is *false*.
176 176
 
177
+**--ip**=""
178
+   Sets the container's interface IPv4 address (e.g. 172.23.0.9)
179
+
180
+   It can only be used in conjunction with **--net** for user-defined networks
181
+
182
+**--ip6**=""
183
+   Sets the container's interface IPv6 address (e.g. 2001:db8::1b99)
184
+
185
+   It can only be used in conjunction with **--net** for user-defined networks
186
+
177 187
 **--ipc**=""
178 188
    Default is to create a private IPC namespace (POSIX SysV IPC) for the container
179 189
                                'container:<name|id>': reuses another container shared memory, semaphores and message queues
... ...
@@ -22,14 +22,26 @@ $ docker network connect multi-host-network container1
22 22
 You can also use the `docker run --net=<network-name>` option to start a container and immediately connect it to a network.
23 23
 
24 24
 ```bash
25
-$ docker run -itd --net=multi-host-network busybox
25
+$ docker run -itd --net=multi-host-network --ip 172.20.88.22 --ip6 2001:db8::8822 busybox
26 26
 ```
27 27
 
28 28
 You can pause, restart, and stop containers that are connected to a network.
29
-Paused containers remain connected and a revealed by a `network inspect`. When
30
-the container is stopped, it does not appear on the network until you restart
31
-it. The container's IP address is not guaranteed to remain the same when a
32
-stopped container rejoins the network.
29
+Paused containers remain connected and can be revealed by a `network inspect`.
30
+When the container is stopped, it does not appear on the network until you restart
31
+it. If specified, the container's IP address(es) will be reapplied (if still available)
32
+when a stopped container rejoins the network. One way to guarantee that the container
33
+will be assigned the same IP addresses when it rejoins the network after a stop
34
+or a disconnect, is to specify the `--ip-range` when creating the network, and choose
35
+the static IP address(es) from outside the range. This will ensure that the IP address
36
+will not be given to other dynamic containers while this container is not on the network.
37
+
38
+```bash
39
+$ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network
40
+```
41
+
42
+```bash
43
+$ docker network connect --ip 172.20.128.2 multi-host-network container2
44
+```
33 45
 
34 46
 To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network.
35 47
 
... ...
@@ -37,6 +37,8 @@ docker-run - Run a command in a new container
37 37
 [**-h**|**--hostname**[=*HOSTNAME*]]
38 38
 [**--help**]
39 39
 [**-i**|**--interactive**]
40
+[**--ip**[=*IPv4-ADDRESS*]]
41
+[**--ip6**[=*IPv6-ADDRESS*]]
40 42
 [**--ipc**[=*IPC*]]
41 43
 [**--isolation**[=*default*]]
42 44
 [**--kernel-memory**[=*KERNEL-MEMORY*]]
... ...
@@ -274,6 +276,16 @@ redirection on the host system.
274 274
 
275 275
    When set to true, keep stdin open even if not attached. The default is false.
276 276
 
277
+**--ip**=""
278
+   Sets the container's interface IPv4 address (e.g. 172.23.0.9)
279
+
280
+   It can only be used in conjunction with **--net** for user-defined networks
281
+
282
+**--ip6**=""
283
+   Sets the container's interface IPv6 address (e.g. 2001:db8::1b99)
284
+
285
+   It can only be used in conjunction with **--net** for user-defined networks
286
+
277 287
 **--ipc**=""
278 288
    Default is to create a private IPC namespace (POSIX SysV IPC) for the container
279 289
                                'container:<name|id>': reuses another container shared memory, semaphores and message queues