mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
9ef855f9e5
Removing old networking.md Updating dockernetworks.md with images Adding information on network plugins Adding blurb about links to docker networking Updating the working documentation Adding Overlay Getting Started Downplaying links by removing refs/examples, adding refs/examples for network. Updating getting started to reflect networks not links Pulling out old network material Updating per discussion with Madhu to add Default docs section Updating with bridge default Fix bad merge Updating with new cluster-advertise behavior Update working and NetworkSettings examples Correcting example for default bridge discovery behavior Entering comments Fixing broken Markdown Syntax Updating with comments Updating all the links Signed-off-by: Mary Anthony <mary@docker.com>
55 lines
2 KiB
Markdown
55 lines
2 KiB
Markdown
<!--[metadata]>
|
|
+++
|
|
title = "network connect"
|
|
description = "The network connect command description and usage"
|
|
keywords = ["network, connect, user-defined"]
|
|
[menu.main]
|
|
parent = "smn_cli"
|
|
+++
|
|
<![end-metadata]-->
|
|
|
|
# network connect
|
|
|
|
Usage: docker network connect [OPTIONS] NETWORK CONTAINER
|
|
|
|
Connects a container to a network
|
|
|
|
--help=false Print usage
|
|
|
|
Connects a running container to a network. You can connect a container by name
|
|
or by ID. Once connected, the container can communicate with other containers in
|
|
the same network.
|
|
|
|
```bash
|
|
$ docker network connect multi-host-network container1
|
|
```
|
|
|
|
You can also use the `docker run --net=<network-name>` option to start a container and immediately connect it to a network.
|
|
|
|
```bash
|
|
$ docker run -itd --net=multi-host-network busybox
|
|
```
|
|
|
|
You can pause, restart, and stop containers that are connected to a network.
|
|
Paused containers remain connected and a revealed by a `network inspect`. When
|
|
the container is stopped, it does not appear on the network until you restart
|
|
it. The container's IP address is not guaranteed to remain the same when a
|
|
stopped container rejoins the network.
|
|
|
|
To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network.
|
|
|
|
Once connected in network, containers can communicate using only another
|
|
container's IP address or name. For `overlay` networks or custom plugins that
|
|
support multi-host connectivity, containers connected to the same multi-host
|
|
network but launched from different Engines can also communicate in this way.
|
|
|
|
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.
|
|
|
|
## Related information
|
|
|
|
* [network inspect](network_inspect.md)
|
|
* [network create](network_create.md)
|
|
* [network disconnect](network_disconnect.md)
|
|
* [network ls](network_ls.md)
|
|
* [network rm](network_rm.md)
|
|
* [Understand Docker container networks](../../userguide/networking/dockernetworks.md)
|