Add a `--network` flag which replaces `--net` without deprecating it
yet. The `--net` flag remains hidden and supported.
Add a `--network-alias` flag which replaces `--net-alias` without deprecating
it yet. The `--net-alias` flag remains hidden and supported.
Signed-off-by: Arnaud Porterie (icecrime) <arnaud.porterie@docker.com>
| ... | ... |
@@ -93,8 +93,8 @@ too. |
| 93 | 93 |
**Option 5** creates a custom network of APT proxy server and Debian-based containers: |
| 94 | 94 |
|
| 95 | 95 |
$ docker network create mynetwork |
| 96 |
- $ docker run -d -p 3142:3142 --net=mynetwork --name test_apt_cacher_ng eg_apt_cacher_ng |
|
| 97 |
- $ docker run --rm -it --net=mynetwork -e http_proxy=http://test_apt_cacher_ng:3142/ debian bash |
|
| 96 |
+ $ docker run -d -p 3142:3142 --network=mynetwork --name test_apt_cacher_ng eg_apt_cacher_ng |
|
| 97 |
+ $ docker run --rm -it --network=mynetwork -e http_proxy=http://test_apt_cacher_ng:3142/ debian bash |
|
| 98 | 98 |
|
| 99 | 99 |
Apt-cacher-ng has some tools that allow you to manage the repository, |
| 100 | 100 |
and they can be used by leveraging the `VOLUME` |
| ... | ... |
@@ -35,7 +35,7 @@ Some network driver plugins are listed in [plugins](plugins.md) |
| 35 | 35 |
The `mynet` network is now owned by `weave`, so subsequent commands |
| 36 | 36 |
referring to that network will be sent to the plugin, |
| 37 | 37 |
|
| 38 |
- $ docker run --net=mynet busybox top |
|
| 38 |
+ $ docker run --network=mynet busybox top |
|
| 39 | 39 |
|
| 40 | 40 |
|
| 41 | 41 |
## Write a network plugin |
| ... | ... |
@@ -72,13 +72,13 @@ Options: |
| 72 | 72 |
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
| 73 | 73 |
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) |
| 74 | 74 |
--name string Assign a name to the container |
| 75 |
- --net string Connect a container to a network (default "default") |
|
| 75 |
+ --network-alias value Add network-scoped alias for the container (default []) |
|
| 76 |
+ --network string Connect a container to a network (default "default") |
|
| 76 | 77 |
'bridge': create a network stack on the default Docker bridge |
| 77 | 78 |
'none': no networking |
| 78 | 79 |
'container:<name|id>': reuse another container's network stack |
| 79 | 80 |
'host': use the Docker host network stack |
| 80 | 81 |
'<network-name>|<network-id>': connect to a user-defined network |
| 81 |
- --net-alias value Add network-scoped alias for the container (default []) |
|
| 82 | 82 |
--no-healthcheck Disable any container-specified HEALTHCHECK |
| 83 | 83 |
--oom-kill-disable Disable OOM Killer |
| 84 | 84 |
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
| ... | ... |
@@ -921,7 +921,7 @@ This option will completely disable user namespace mapping for the container's u |
| 921 | 921 |
The following standard Docker features are currently incompatible when |
| 922 | 922 |
running a Docker daemon with user namespaces enabled: |
| 923 | 923 |
|
| 924 |
- - sharing PID or NET namespaces with the host (`--pid=host` or `--net=host`) |
|
| 924 |
+ - sharing PID or NET namespaces with the host (`--pid=host` or `--network=host`) |
|
| 925 | 925 |
- A `--read-only` container filesystem (this is a Linux kernel restriction against remounting with modified flags of a currently mounted filesystem when inside a user namespace) |
| 926 | 926 |
- external (volume or graph) drivers which are unaware/incapable of using daemon user mappings |
| 927 | 927 |
- Using `--privileged` mode flag on `docker run` (unless also specifying `--userns=host`) |
| ... | ... |
@@ -32,10 +32,10 @@ the same network. |
| 32 | 32 |
$ docker network connect multi-host-network container1 |
| 33 | 33 |
``` |
| 34 | 34 |
|
| 35 |
-You can also use the `docker run --net=<network-name>` option to start a container and immediately connect it to a network. |
|
| 35 |
+You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network. |
|
| 36 | 36 |
|
| 37 | 37 |
```bash |
| 38 |
-$ docker run -itd --net=multi-host-network busybox |
|
| 38 |
+$ docker run -itd --network=multi-host-network busybox |
|
| 39 | 39 |
``` |
| 40 | 40 |
|
| 41 | 41 |
You can specify the IP address you want to be assigned to the container's interface. |
| ... | ... |
@@ -82,11 +82,11 @@ name conflicts. |
| 82 | 82 |
|
| 83 | 83 |
## Connect containers |
| 84 | 84 |
|
| 85 |
-When you start a container, use the `--net` flag to connect it to a network. |
|
| 85 |
+When you start a container, use the `--network` flag to connect it to a network. |
|
| 86 | 86 |
This example adds the `busybox` container to the `mynet` network: |
| 87 | 87 |
|
| 88 | 88 |
```bash |
| 89 |
-$ docker run -itd --net=mynet busybox |
|
| 89 |
+$ docker run -itd --network=mynet busybox |
|
| 90 | 90 |
``` |
| 91 | 91 |
|
| 92 | 92 |
If you want to add a container to a network after the container is already |
| ... | ... |
@@ -78,13 +78,13 @@ Options: |
| 78 | 78 |
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
| 79 | 79 |
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1). |
| 80 | 80 |
--name string Assign a name to the container |
| 81 |
- --net string Connect a container to a network (default "default") |
|
| 81 |
+ --network-alias value Add network-scoped alias for the container (default []) |
|
| 82 |
+ --network string Connect a container to a network |
|
| 82 | 83 |
'bridge': create a network stack on the default Docker bridge |
| 83 | 84 |
'none': no networking |
| 84 | 85 |
'container:<name|id>': reuse another container's network stack |
| 85 | 86 |
'host': use the Docker host network stack |
| 86 | 87 |
'<network-name>|<network-id>': connect to a user-defined network |
| 87 |
- --net-alias value Add network-scoped alias for the container (default []) |
|
| 88 | 88 |
--no-healthcheck Disable any container-specified HEALTHCHECK |
| 89 | 89 |
--oom-kill-disable Disable OOM Killer |
| 90 | 90 |
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
| ... | ... |
@@ -360,20 +360,20 @@ For additional information on working with labels, see [*Labels - custom |
| 360 | 360 |
metadata in Docker*](../../userguide/labels-custom-metadata.md) in the Docker User |
| 361 | 361 |
Guide. |
| 362 | 362 |
|
| 363 |
-### Connect a container to a network (--net) |
|
| 363 |
+### Connect a container to a network (--network) |
|
| 364 | 364 |
|
| 365 |
-When you start a container use the `--net` flag to connect it to a network. |
|
| 365 |
+When you start a container use the `--network` flag to connect it to a network. |
|
| 366 | 366 |
This adds the `busybox` container to the `my-net` network. |
| 367 | 367 |
|
| 368 | 368 |
```bash |
| 369 |
-$ docker run -itd --net=my-net busybox |
|
| 369 |
+$ docker run -itd --network=my-net busybox |
|
| 370 | 370 |
``` |
| 371 | 371 |
|
| 372 | 372 |
You can also choose the IP addresses for the container with `--ip` and `--ip6` |
| 373 | 373 |
flags when you start the container on a user-defined network. |
| 374 | 374 |
|
| 375 | 375 |
```bash |
| 376 |
-$ docker run -itd --net=my-net --ip=10.10.9.75 busybox |
|
| 376 |
+$ docker run -itd --network=my-net --ip=10.10.9.75 busybox |
|
| 377 | 377 |
``` |
| 378 | 378 |
|
| 379 | 379 |
If you want to add a running container to a network use the `docker network connect` subcommand. |
| ... | ... |
@@ -673,4 +673,4 @@ network namespace, run this command: |
| 673 | 673 |
`Network Namespace`: |
| 674 | 674 |
Sysctls beginning with net.* |
| 675 | 675 |
|
| 676 |
- If you use the `--net=host` option using these sysctls will not be allowed. |
|
| 676 |
+ If you use the `--network=host` option using these sysctls will not be allowed. |
| ... | ... |
@@ -259,7 +259,7 @@ $ strace -p 1 |
| 259 | 259 |
|
| 260 | 260 |
The UTS namespace is for setting the hostname and the domain that is visible |
| 261 | 261 |
to running processes in that namespace. By default, all containers, including |
| 262 |
-those with `--net=host`, have their own UTS namespace. The `host` setting will |
|
| 262 |
+those with `--network=host`, have their own UTS namespace. The `host` setting will |
|
| 263 | 263 |
result in the container using the same UTS namespace as the host. Note that |
| 264 | 264 |
`--hostname` is invalid in `host` UTS mode. |
| 265 | 265 |
|
| ... | ... |
@@ -289,13 +289,13 @@ of the containers. |
| 289 | 289 |
## Network settings |
| 290 | 290 |
|
| 291 | 291 |
--dns=[] : Set custom dns servers for the container |
| 292 |
- --net="bridge" : Connect a container to a network |
|
| 292 |
+ --network="bridge" : Connect a container to a network |
|
| 293 | 293 |
'bridge': create a network stack on the default Docker bridge |
| 294 | 294 |
'none': no networking |
| 295 | 295 |
'container:<name|id>': reuse another container's network stack |
| 296 | 296 |
'host': use the Docker host network stack |
| 297 | 297 |
'<network-name>|<network-id>': connect to a user-defined network |
| 298 |
- --net-alias=[] : Add network-scoped alias for the container |
|
| 298 |
+ --network-alias=[] : Add network-scoped alias for the container |
|
| 299 | 299 |
--add-host="" : Add a line to /etc/hosts (host:IP) |
| 300 | 300 |
--mac-address="" : Sets the container's Ethernet device's MAC address |
| 301 | 301 |
--ip="" : Sets the container's Ethernet device's IPv4 address |
| ... | ... |
@@ -304,7 +304,7 @@ of the containers. |
| 304 | 304 |
|
| 305 | 305 |
By default, all containers have networking enabled and they can make any |
| 306 | 306 |
outgoing connections. The operator can completely disable networking |
| 307 |
-with `docker run --net none` which disables all incoming and outgoing |
|
| 307 |
+with `docker run --network none` which disables all incoming and outgoing |
|
| 308 | 308 |
networking. In cases like this, you would perform I/O through files or |
| 309 | 309 |
`STDIN` and `STDOUT` only. |
| 310 | 310 |
|
| ... | ... |
@@ -404,14 +404,14 @@ docker daemon. It is recommended to run containers in this mode when their |
| 404 | 404 |
networking performance is critical, for example, a production Load Balancer |
| 405 | 405 |
or a High Performance Web Server. |
| 406 | 406 |
|
| 407 |
-> **Note**: `--net="host"` gives the container full access to local system |
|
| 407 |
+> **Note**: `--network="host"` gives the container full access to local system |
|
| 408 | 408 |
> services such as D-bus and is therefore considered insecure. |
| 409 | 409 |
|
| 410 | 410 |
#### Network: container |
| 411 | 411 |
|
| 412 | 412 |
With the network set to `container` a container will share the |
| 413 | 413 |
network stack of another container. The other container's name must be |
| 414 |
-provided in the format of `--net container:<name|id>`. Note that `--add-host` |
|
| 414 |
+provided in the format of `--network container:<name|id>`. Note that `--add-host` |
|
| 415 | 415 |
`--hostname` `--dns` `--dns-search` `--dns-opt` and `--mac-address` are |
| 416 | 416 |
invalid in `container` netmode, and `--publish` `--publish-all` `--expose` are |
| 417 | 417 |
also invalid in `container` netmode. |
| ... | ... |
@@ -422,7 +422,7 @@ running the `redis-cli` command and connecting to the Redis server over the |
| 422 | 422 |
|
| 423 | 423 |
$ docker run -d --name redis example/redis --bind 127.0.0.1 |
| 424 | 424 |
$ # use the redis container's network stack to access localhost |
| 425 |
- $ docker run --rm -it --net container:redis example/redis-cli -h 127.0.0.1 |
|
| 425 |
+ $ docker run --rm -it --network container:redis example/redis-cli -h 127.0.0.1 |
|
| 426 | 426 |
|
| 427 | 427 |
#### User-defined network |
| 428 | 428 |
|
| ... | ... |
@@ -440,7 +440,7 @@ driver and running a container in the created network |
| 440 | 440 |
|
| 441 | 441 |
``` |
| 442 | 442 |
$ docker network create -d bridge my-net |
| 443 |
-$ docker run --net=my-net -itd --name=container3 busybox |
|
| 443 |
+$ docker run --network=my-net -itd --name=container3 busybox |
|
| 444 | 444 |
``` |
| 445 | 445 |
|
| 446 | 446 |
### Managing /etc/hosts |
| ... | ... |
@@ -198,9 +198,9 @@ To build web applications that act in concert but do so securely, create a |
| 198 | 198 |
network. Networks, by definition, provide complete isolation for containers. You |
| 199 | 199 |
can add containers to a network when you first run a container. |
| 200 | 200 |
|
| 201 |
-Launch a container running a PostgreSQL database and pass it the `--net=my-bridge-network` flag to connect it to your new network: |
|
| 201 |
+Launch a container running a PostgreSQL database and pass it the `--network=my-bridge-network` flag to connect it to your new network: |
|
| 202 | 202 |
|
| 203 |
- $ docker run -d --net=my-bridge-network --name db training/postgres |
|
| 203 |
+ $ docker run -d --network=my-bridge-network --name db training/postgres |
|
| 204 | 204 |
|
| 205 | 205 |
If you inspect your `my-bridge-network` you'll see it has a container attached. |
| 206 | 206 |
You can also inspect your container to see where it is connected: |
| ... | ... |
@@ -48,13 +48,13 @@ Various container options that affect container domain name services. |
| 48 | 48 |
<tr> |
| 49 | 49 |
<td> |
| 50 | 50 |
<p> |
| 51 |
- <code>--net-alias=ALIAS</code> |
|
| 51 |
+ <code>--network-alias=ALIAS</code> |
|
| 52 | 52 |
</p> |
| 53 | 53 |
</td> |
| 54 | 54 |
<td> |
| 55 | 55 |
<p> |
| 56 | 56 |
In addition to <code>--name</code> as described above, a container is discovered by one or more |
| 57 |
- of its configured <code>--net-alias</code> (or <code>--alias</code> in <code>docker network connect</code> command) |
|
| 57 |
+ of its configured <code>--network-alias</code> (or <code>--alias</code> in <code>docker network connect</code> command) |
|
| 58 | 58 |
within the user-defined network. The embedded DNS server maintains the mapping between |
| 59 | 59 |
all of the container aliases and its IP address on a specific user-defined network. |
| 60 | 60 |
A container can have different aliases in different networks by using the <code>--alias</code> |
| ... | ... |
@@ -42,7 +42,7 @@ or to turn it on manually: |
| 42 | 42 |
``` |
| 43 | 43 |
|
| 44 | 44 |
> **Note**: this setting does not affect containers that use the host |
| 45 |
-> network stack (`--net=host`). |
|
| 45 |
+> network stack (`--network=host`). |
|
| 46 | 46 |
|
| 47 | 47 |
Many using Docker will want `ip_forward` to be on, to at least make |
| 48 | 48 |
communication _possible_ between containers and the wider world. May also be |
| ... | ... |
@@ -37,12 +37,12 @@ cf03ee007fb4 host host |
| 37 | 37 |
``` |
| 38 | 38 |
|
| 39 | 39 |
Historically, these three networks are part of Docker's implementation. When |
| 40 |
-you run a container you can use the `--net` flag to specify which network you |
|
| 40 |
+you run a container you can use the `--network` flag to specify which network you |
|
| 41 | 41 |
want to run a container on. These three networks are still available to you. |
| 42 | 42 |
|
| 43 | 43 |
The `bridge` network represents the `docker0` network present in all Docker |
| 44 | 44 |
installations. Unless you specify otherwise with the `docker run |
| 45 |
+--network=<NETWORK>` option, the Docker daemon connects containers to this network |
|
| 45 | 46 |
by default. You can see this bridge as part of a host's network stack by using |
| 46 | 47 |
the `ifconfig` command on the host. |
| 47 | 48 |
|
| ... | ... |
@@ -352,10 +352,10 @@ c5ee82f76de3 isolated_nw bridge |
| 352 | 352 |
|
| 353 | 353 |
``` |
| 354 | 354 |
|
| 355 |
-After you create the network, you can launch containers on it using the `docker run --net=<NETWORK>` option. |
|
| 355 |
+After you create the network, you can launch containers on it using the `docker run --network=<NETWORK>` option. |
|
| 356 | 356 |
|
| 357 | 357 |
``` |
| 358 |
-$ docker run --net=isolated_nw -itd --name=container3 busybox |
|
| 358 |
+$ docker run --network=isolated_nw -itd --name=container3 busybox |
|
| 359 | 359 |
|
| 360 | 360 |
8c1a0a5be480921d669a073393ade66a3fc49933f08bcc5515b37b8144f6d47c |
| 361 | 361 |
|
| ... | ... |
@@ -473,7 +473,7 @@ provides complete isolation for the containers. |
| 473 | 473 |
|
| 474 | 474 |
Then, on each host, launch containers making sure to specify the network name. |
| 475 | 475 |
|
| 476 |
- $ docker run -itd --net=my-multi-host-network busybox |
|
| 476 |
+ $ docker run -itd --network=my-multi-host-network busybox |
|
| 477 | 477 |
|
| 478 | 478 |
Once connected, each container has access to all the containers in the network |
| 479 | 479 |
regardless of which Docker host the container was launched on. |
| ... | ... |
@@ -223,11 +223,11 @@ Once your network is created, you can start a container on any of the hosts and |
| 223 | 223 |
|
| 224 | 224 |
2. Start an Nginx web server on the `mhs-demo0` instance. |
| 225 | 225 |
|
| 226 |
- $ docker run -itd --name=web --net=my-net --env="constraint:node==mhs-demo0" nginx |
|
| 226 |
+ $ docker run -itd --name=web --network=my-net --env="constraint:node==mhs-demo0" nginx |
|
| 227 | 227 |
|
| 228 | 228 |
4. Run a BusyBox instance on the `mhs-demo1` instance and get the contents of the Nginx server's home page. |
| 229 | 229 |
|
| 230 |
- $ docker run -it --rm --net=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web |
|
| 230 |
+ $ docker run -it --rm --network=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web |
|
| 231 | 231 |
|
| 232 | 232 |
Unable to find image 'busybox:latest' locally |
| 233 | 233 |
latest: Pulling from library/busybox |
| ... | ... |
@@ -164,7 +164,7 @@ $ docker network inspect my-network |
| 164 | 164 |
} |
| 165 | 165 |
] |
| 166 | 166 |
|
| 167 |
-$ docker run -d -P --name redis --net my-network redis |
|
| 167 |
+$ docker run -d -P --name redis --network my-network redis |
|
| 168 | 168 |
|
| 169 | 169 |
bafb0c808c53104b2c90346f284bda33a69beadcab4fc83ab8f2c5a4410cd129 |
| 170 | 170 |
|
| ... | ... |
@@ -244,10 +244,10 @@ $ docker network inspect isolated_nw |
| 244 | 244 |
You can see that the Engine automatically assigns an IP address to `container2`. |
| 245 | 245 |
Given we specified a `--subnet` when creating the network, Engine picked |
| 246 | 246 |
an address from that same subnet. Now, start a third container and connect it to |
| 247 |
-the network on launch using the `docker run` command's `--net` option: |
|
| 247 |
+the network on launch using the `docker run` command's `--network` option: |
|
| 248 | 248 |
|
| 249 | 249 |
```bash |
| 250 |
-$ docker run --net=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox |
|
| 250 |
+$ docker run --network=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox |
|
| 251 | 251 |
|
| 252 | 252 |
467a7863c3f0277ef8e661b38427737f28099b61fa55622d6c30fb288d88c551 |
| 253 | 253 |
``` |
| ... | ... |
@@ -450,7 +450,7 @@ Continuing with the above example, create another container `container4` in |
| 450 | 450 |
for other containers in the same network. |
| 451 | 451 |
|
| 452 | 452 |
```bash |
| 453 |
-$ docker run --net=isolated_nw -itd --name=container4 --link container5:c5 busybox |
|
| 453 |
+$ docker run --network=isolated_nw -itd --name=container4 --link container5:c5 busybox |
|
| 454 | 454 |
|
| 455 | 455 |
01b5df970834b77a9eadbaff39051f237957bd35c4c56f11193e0594cfd5117c |
| 456 | 456 |
``` |
| ... | ... |
@@ -471,7 +471,7 @@ Now let us launch another container named `container5` linking `container4` to |
| 471 | 471 |
c4. |
| 472 | 472 |
|
| 473 | 473 |
```bash |
| 474 |
-$ docker run --net=isolated_nw -itd --name=container5 --link container4:c4 busybox |
|
| 474 |
+$ docker run --network=isolated_nw -itd --name=container5 --link container4:c4 busybox |
|
| 475 | 475 |
|
| 476 | 476 |
72eccf2208336f31e9e33ba327734125af00d1e1d2657878e2ee8154fbb23c7a |
| 477 | 477 |
``` |
| ... | ... |
@@ -629,7 +629,7 @@ Continuing with the above example, create another container in `isolated_nw` |
| 629 | 629 |
with a network alias. |
| 630 | 630 |
|
| 631 | 631 |
```bash |
| 632 |
-$ docker run --net=isolated_nw -itd --name=container6 --net-alias app busybox |
|
| 632 |
+$ docker run --network=isolated_nw -itd --name=container6 --network-alias app busybox |
|
| 633 | 633 |
|
| 634 | 634 |
8ebe6767c1e0361f27433090060b33200aac054a68476c3be87ef4005eb1df17 |
| 635 | 635 |
``` |
| ... | ... |
@@ -702,7 +702,7 @@ network-scoped alias within the same network. For example, let's launch |
| 702 | 702 |
`container7` in `isolated_nw` with the same alias as `container6` |
| 703 | 703 |
|
| 704 | 704 |
```bash |
| 705 |
-$ docker run --net=isolated_nw -itd --name=container7 --net-alias app busybox |
|
| 705 |
+$ docker run --network=isolated_nw -itd --name=container7 --network-alias app busybox |
|
| 706 | 706 |
|
| 707 | 707 |
3138c678c123b8799f4c7cc6a0cecc595acbdfa8bf81f621834103cd4f504554 |
| 708 | 708 |
``` |
| ... | ... |
@@ -859,7 +859,7 @@ endpoint from the network. Once the endpoint is cleaned up, the container can |
| 859 | 859 |
be connected to the network. |
| 860 | 860 |
|
| 861 | 861 |
```bash |
| 862 |
-$ docker run -d --name redis_db --net multihost redis |
|
| 862 |
+$ docker run -d --name redis_db --network multihost redis |
|
| 863 | 863 |
|
| 864 | 864 |
ERROR: Cannot start container bc0b19c089978f7845633027aa3435624ca3d12dd4f4f764b61eac4c0610f32e: container already connected to network multihost |
| 865 | 865 |
|
| ... | ... |
@@ -867,7 +867,7 @@ $ docker rm -f redis_db |
| 867 | 867 |
|
| 868 | 868 |
$ docker network disconnect -f multihost redis_db |
| 869 | 869 |
|
| 870 |
-$ docker run -d --name redis_db --net multihost redis |
|
| 870 |
+$ docker run -d --name redis_db --network multihost redis |
|
| 871 | 871 |
|
| 872 | 872 |
7d986da974aeea5e9f7aca7e510bdb216d58682faa83a9040c2f2adc0544795a |
| 873 | 873 |
``` |
| ... | ... |
@@ -1660,3 +1660,15 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
|
| 1660 | 1660 |
t.Fatal(err) |
| 1661 | 1661 |
} |
| 1662 | 1662 |
} |
| 1663 |
+ |
|
| 1664 |
+func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *check.C) {
|
|
| 1665 |
+ dockerCmd(c, "network", "create", "user") |
|
| 1666 |
+ output, status := dockerCmd(c, "run", "--rm", "--network=user", "--network-alias=foo", "busybox", "true") |
|
| 1667 |
+ c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
|
|
| 1668 |
+ |
|
| 1669 |
+ output, status, _ = dockerCmdWithError("run", "--rm", "--net=user", "--network=user", "busybox", "true")
|
|
| 1670 |
+ c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
|
|
| 1671 |
+ |
|
| 1672 |
+ output, status, _ = dockerCmdWithError("run", "--rm", "--network=user", "--net-alias=foo", "--network-alias=bar", "busybox", "true")
|
|
| 1673 |
+ c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
|
|
| 1674 |
+} |
| ... | ... |
@@ -52,8 +52,8 @@ docker-create - Create a new container |
| 52 | 52 |
[**--memory-swap**[=*LIMIT*]] |
| 53 | 53 |
[**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] |
| 54 | 54 |
[**--name**[=*NAME*]] |
| 55 |
-[**--net**[=*"bridge"*]] |
|
| 56 |
-[**--net-alias**[=*[]*]] |
|
| 55 |
+[**--network-alias**[=*[]*]] |
|
| 56 |
+[**--network**[=*"bridge"*]] |
|
| 57 | 57 |
[**--oom-kill-disable**] |
| 58 | 58 |
[**--oom-score-adj**[=*0*]] |
| 59 | 59 |
[**-P**|**--publish-all**] |
| ... | ... |
@@ -276,7 +276,7 @@ unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap. |
| 276 | 276 |
'host': use the Docker host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. |
| 277 | 277 |
'<network-name>|<network-id>': connect to a user-defined network |
| 278 | 278 |
|
| 279 |
-**--net-alias**=[] |
|
| 279 |
+**--network-alias**=[] |
|
| 280 | 280 |
Add network-scoped alias for the container |
| 281 | 281 |
|
| 282 | 282 |
**--oom-kill-disable**=*true*|*false* |
| ... | ... |
@@ -54,8 +54,8 @@ docker-run - Run a command in a new container |
| 54 | 54 |
[**--memory-swap**[=*LIMIT*]] |
| 55 | 55 |
[**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] |
| 56 | 56 |
[**--name**[=*NAME*]] |
| 57 |
-[**--net**[=*"bridge"*]] |
|
| 58 |
-[**--net-alias**[=*[]*]] |
|
| 57 |
+[**--network-alias**[=*[]*]] |
|
| 58 |
+[**--network**[=*"bridge"*]] |
|
| 59 | 59 |
[**--oom-kill-disable**] |
| 60 | 60 |
[**--oom-score-adj**[=*0*]] |
| 61 | 61 |
[**-P**|**--publish-all**] |
| ... | ... |
@@ -395,7 +395,7 @@ and foreground Docker containers. |
| 395 | 395 |
'host': use the Docker host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. |
| 396 | 396 |
'<network-name>|<network-id>': connect to a user-defined network |
| 397 | 397 |
|
| 398 |
-**--net-alias**=[] |
|
| 398 |
+**--network-alias**=[] |
|
| 399 | 399 |
Add network-scoped alias for the container |
| 400 | 400 |
|
| 401 | 401 |
**--oom-kill-disable**=*true*|*false* |
| ... | ... |
@@ -182,10 +182,16 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
|
| 182 | 182 |
flags.Var(&copts.flLinks, "link", "Add link to another container") |
| 183 | 183 |
flags.Var(&copts.flLinkLocalIPs, "link-local-ip", "Container IPv4/IPv6 link-local addresses") |
| 184 | 184 |
flags.StringVar(&copts.flMacAddress, "mac-address", "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)") |
| 185 |
- flags.StringVar(&copts.flNetMode, "net", "default", "Connect a container to a network") |
|
| 186 |
- flags.Var(&copts.flAliases, "net-alias", "Add network-scoped alias for the container") |
|
| 187 | 185 |
flags.VarP(&copts.flPublish, "publish", "p", "Publish a container's port(s) to the host") |
| 188 | 186 |
flags.BoolVarP(&copts.flPublishAll, "publish-all", "P", false, "Publish all exposed ports to random ports") |
| 187 |
+ // We allow for both "--net" and "--network", although the latter is the recommended way. |
|
| 188 |
+ flags.StringVar(&copts.flNetMode, "net", "default", "Connect a container to a network") |
|
| 189 |
+ flags.StringVar(&copts.flNetMode, "network", "default", "Connect a container to a network") |
|
| 190 |
+ flags.MarkHidden("net")
|
|
| 191 |
+ // We allow for both "--net-alias" and "--network-alias", although the latter is the recommended way. |
|
| 192 |
+ flags.Var(&copts.flAliases, "net-alias", "Add network-scoped alias for the container") |
|
| 193 |
+ flags.Var(&copts.flAliases, "network-alias", "Add network-scoped alias for the container") |
|
| 194 |
+ flags.MarkHidden("net-alias")
|
|
| 189 | 195 |
|
| 190 | 196 |
// Logging and storage |
| 191 | 197 |
flags.StringVar(&copts.flLoggingDriver, "log-driver", "", "Logging driver for container") |