Rename --net to --network
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> Upstream-commit: c0c7d5e71586ec8e4d54aef9e061f061e9223cc4 Component: engine
This commit is contained in:
@ -48,13 +48,13 @@ Various container options that affect container domain name services.
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code>--net-alias=ALIAS</code>
|
||||
<code>--network-alias=ALIAS</code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
In addition to <code>--name</code> as described above, a container is discovered by one or more
|
||||
of its configured <code>--net-alias</code> (or <code>--alias</code> in <code>docker network connect</code> command)
|
||||
of its configured <code>--network-alias</code> (or <code>--alias</code> in <code>docker network connect</code> command)
|
||||
within the user-defined network. The embedded DNS server maintains the mapping between
|
||||
all of the container aliases and its IP address on a specific user-defined network.
|
||||
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:
|
||||
```
|
||||
|
||||
> **Note**: this setting does not affect containers that use the host
|
||||
> network stack (`--net=host`).
|
||||
> network stack (`--network=host`).
|
||||
|
||||
Many using Docker will want `ip_forward` to be on, to at least make
|
||||
communication _possible_ between containers and the wider world. May also be
|
||||
|
||||
@ -37,12 +37,12 @@ cf03ee007fb4 host host
|
||||
```
|
||||
|
||||
Historically, these three networks are part of Docker's implementation. When
|
||||
you run a container you can use the `--net` flag to specify which network you
|
||||
you run a container you can use the `--network` flag to specify which network you
|
||||
want to run a container on. These three networks are still available to you.
|
||||
|
||||
The `bridge` network represents the `docker0` network present in all Docker
|
||||
installations. Unless you specify otherwise with the `docker run
|
||||
--net=<NETWORK>` option, the Docker daemon connects containers to this network
|
||||
--network=<NETWORK>` option, the Docker daemon connects containers to this network
|
||||
by default. You can see this bridge as part of a host's network stack by using
|
||||
the `ifconfig` command on the host.
|
||||
|
||||
@ -352,10 +352,10 @@ c5ee82f76de3 isolated_nw bridge
|
||||
|
||||
```
|
||||
|
||||
After you create the network, you can launch containers on it using the `docker run --net=<NETWORK>` option.
|
||||
After you create the network, you can launch containers on it using the `docker run --network=<NETWORK>` option.
|
||||
|
||||
```
|
||||
$ docker run --net=isolated_nw -itd --name=container3 busybox
|
||||
$ docker run --network=isolated_nw -itd --name=container3 busybox
|
||||
|
||||
8c1a0a5be480921d669a073393ade66a3fc49933f08bcc5515b37b8144f6d47c
|
||||
|
||||
@ -473,7 +473,7 @@ provides complete isolation for the containers.
|
||||
|
||||
Then, on each host, launch containers making sure to specify the network name.
|
||||
|
||||
$ docker run -itd --net=my-multi-host-network busybox
|
||||
$ docker run -itd --network=my-multi-host-network busybox
|
||||
|
||||
Once connected, each container has access to all the containers in the network
|
||||
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
|
||||
|
||||
2. Start an Nginx web server on the `mhs-demo0` instance.
|
||||
|
||||
$ docker run -itd --name=web --net=my-net --env="constraint:node==mhs-demo0" nginx
|
||||
$ docker run -itd --name=web --network=my-net --env="constraint:node==mhs-demo0" nginx
|
||||
|
||||
4. Run a BusyBox instance on the `mhs-demo1` instance and get the contents of the Nginx server's home page.
|
||||
|
||||
$ docker run -it --rm --net=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web
|
||||
$ docker run -it --rm --network=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web
|
||||
|
||||
Unable to find image 'busybox:latest' locally
|
||||
latest: Pulling from library/busybox
|
||||
|
||||
@ -164,7 +164,7 @@ $ docker network inspect my-network
|
||||
}
|
||||
]
|
||||
|
||||
$ docker run -d -P --name redis --net my-network redis
|
||||
$ docker run -d -P --name redis --network my-network redis
|
||||
|
||||
bafb0c808c53104b2c90346f284bda33a69beadcab4fc83ab8f2c5a4410cd129
|
||||
|
||||
@ -244,10 +244,10 @@ $ docker network inspect isolated_nw
|
||||
You can see that the Engine automatically assigns an IP address to `container2`.
|
||||
Given we specified a `--subnet` when creating the network, Engine picked
|
||||
an address from that same subnet. Now, start a third container and connect it to
|
||||
the network on launch using the `docker run` command's `--net` option:
|
||||
the network on launch using the `docker run` command's `--network` option:
|
||||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox
|
||||
$ docker run --network=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox
|
||||
|
||||
467a7863c3f0277ef8e661b38427737f28099b61fa55622d6c30fb288d88c551
|
||||
```
|
||||
@ -450,7 +450,7 @@ Continuing with the above example, create another container `container4` in
|
||||
for other containers in the same network.
|
||||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container4 --link container5:c5 busybox
|
||||
$ docker run --network=isolated_nw -itd --name=container4 --link container5:c5 busybox
|
||||
|
||||
01b5df970834b77a9eadbaff39051f237957bd35c4c56f11193e0594cfd5117c
|
||||
```
|
||||
@ -471,7 +471,7 @@ Now let us launch another container named `container5` linking `container4` to
|
||||
c4.
|
||||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container5 --link container4:c4 busybox
|
||||
$ docker run --network=isolated_nw -itd --name=container5 --link container4:c4 busybox
|
||||
|
||||
72eccf2208336f31e9e33ba327734125af00d1e1d2657878e2ee8154fbb23c7a
|
||||
```
|
||||
@ -629,7 +629,7 @@ Continuing with the above example, create another container in `isolated_nw`
|
||||
with a network alias.
|
||||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container6 --net-alias app busybox
|
||||
$ docker run --network=isolated_nw -itd --name=container6 --network-alias app busybox
|
||||
|
||||
8ebe6767c1e0361f27433090060b33200aac054a68476c3be87ef4005eb1df17
|
||||
```
|
||||
@ -702,7 +702,7 @@ network-scoped alias within the same network. For example, let's launch
|
||||
`container7` in `isolated_nw` with the same alias as `container6`
|
||||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container7 --net-alias app busybox
|
||||
$ docker run --network=isolated_nw -itd --name=container7 --network-alias app busybox
|
||||
|
||||
3138c678c123b8799f4c7cc6a0cecc595acbdfa8bf81f621834103cd4f504554
|
||||
```
|
||||
@ -859,7 +859,7 @@ endpoint from the network. Once the endpoint is cleaned up, the container can
|
||||
be connected to the network.
|
||||
|
||||
```bash
|
||||
$ docker run -d --name redis_db --net multihost redis
|
||||
$ docker run -d --name redis_db --network multihost redis
|
||||
|
||||
ERROR: Cannot start container bc0b19c089978f7845633027aa3435624ca3d12dd4f4f764b61eac4c0610f32e: container already connected to network multihost
|
||||
|
||||
@ -867,7 +867,7 @@ $ docker rm -f redis_db
|
||||
|
||||
$ docker network disconnect -f multihost redis_db
|
||||
|
||||
$ docker run -d --name redis_db --net multihost redis
|
||||
$ docker run -d --name redis_db --network multihost redis
|
||||
|
||||
7d986da974aeea5e9f7aca7e510bdb216d58682faa83a9040c2f2adc0544795a
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user