github.com/tompao/docker@v1.9.1/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=false Print usage 18 19 Connects a running container to a network. You can connect a container by name 20 or by ID. Once connected, the container can communicate with other containers in 21 the same network. 22 23 ```bash 24 $ docker network connect multi-host-network container1 25 ``` 26 27 You can also use the `docker run --net=<network-name>` option to start a container and immediately connect it to a network. 28 29 ```bash 30 $ docker run -itd --net=multi-host-network busybox 31 ``` 32 33 You can pause, restart, and stop containers that are connected to a network. 34 Paused containers remain connected and a revealed by a `network inspect`. When 35 the container is stopped, it does not appear on the network until you restart 36 it. The container's IP address is not guaranteed to remain the same when a 37 stopped container rejoins the network. 38 39 To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network. 40 41 Once connected in network, containers can communicate using only another 42 container's IP address or name. For `overlay` networks or custom plugins that 43 support multi-host connectivity, containers connected to the same multi-host 44 network but launched from different Engines can also communicate in this way. 45 46 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. 47 48 ## Related information 49 50 * [network inspect](network_inspect.md) 51 * [network create](network_create.md) 52 * [network disconnect](network_disconnect.md) 53 * [network ls](network_ls.md) 54 * [network rm](network_rm.md) 55 * [Understand Docker container networks](../../userguide/networking/dockernetworks.md)