github.com/endocode/docker@v1.4.2-0.20160113120958-46eb4700391e/docs/reference/commandline/network_connect.md (about) 1 <!--[metadata]> 2 +++ 3 title = "network connect" 4 description = "The network connect command description and usage" 5 keywords = ["network, connect, user-defined"] 6 [menu.main] 7 parent = "smn_cli" 8 +++ 9 <![end-metadata]--> 10 11 # network connect 12 13 Usage: docker network connect [OPTIONS] NETWORK CONTAINER 14 15 Connects a container to a network 16 17 --help Print usage 18 --ip IP Address 19 --ip6 IPv6 Address 20 --link=[] Add a link to another container 21 22 Connects a container to a network. You can connect a container by name 23 or by ID. Once connected, the container can communicate with other containers in 24 the same network. 25 26 ```bash 27 $ docker network connect multi-host-network container1 28 ``` 29 30 You can also use the `docker run --net=<network-name>` option to start a container and immediately connect it to a network. 31 32 ```bash 33 $ docker run -itd --net=multi-host-network busybox 34 ``` 35 36 You can specify the IP address you want to be assigned to the container's interface. 37 38 ```bash 39 $ docker network connect --ip 10.10.36.122 multi-host-network container2 40 ``` 41 42 You can use `--link` option to link another container with a prefered alias 43 44 ```bash 45 $ docker network connect --link container1:c1 multi-host-network container2 46 ``` 47 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. 54 55 To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network. 56 57 Once connected in network, containers can communicate using only another 58 container's IP address or name. For `overlay` networks or custom plugins that 59 support multi-host connectivity, containers connected to the same multi-host 60 network but launched from different Engines can also communicate in this way. 61 62 You can connect a container to one or more networks. The networks need not be the same type. For example, you can connect a single container bridge and overlay networks. 63 64 ## Related information 65 66 * [network inspect](network_inspect.md) 67 * [network create](network_create.md) 68 * [network disconnect](network_disconnect.md) 69 * [network ls](network_ls.md) 70 * [network rm](network_rm.md) 71 * [Understand Docker container networks](../../userguide/networking/dockernetworks.md) 72 * [Work with networks](../../userguide/networking/work-with-networks.md)