1DOCKER(1)                          OCT 2015                          DOCKER(1)
2
3
4

NAME

6       docker-network-connect - connect a container to a network
7
8
9

SYNOPSIS

11       docker network connect [--help] NETWORK CONTAINER
12
13
14

DESCRIPTION

16       Connects a container to a network. You can connect a container by name
17       or by ID. Once connected, the container can communicate with other
18       containers in the same network.
19
20
21              $ docker network connect multi-host-network container1
22
23
24
25       You can also use the docker run --network=<network-name> option to
26       start a container and immediately connect it to a network.
27
28
29              $ docker run -itd --network=multi-host-network --ip 172.20.88.22 --ip6 2001:db8::8822 busybox
30
31
32
33       You can pause, restart, and stop containers that are connected to a
34       network.  A container connects to its configured networks when it runs.
35
36
37       If specified, the container's IP address(es) is reapplied when a
38       stopped container is restarted. If the IP address is no longer
39       available, the container fails to start. One way to guarantee that the
40       IP address is available is to specify an --ip-range when creating the
41       network, and choose the static IP address(es) from outside that range.
42       This ensures that the IP address is not given to another container
43       while this container is not on the network.
44
45
46              $ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network
47
48
49
50              $ docker network connect --ip 172.20.128.2 multi-host-network container2
51
52
53
54       To verify the container is connected, use the docker network inspect
55       command. Use docker network disconnect to remove a container from the
56       network.
57
58
59       Once connected in network, containers can communicate using only
60       another container's IP address or name. For overlay networks or custom
61       plugins that support multi-host connectivity, containers connected to
62       the same multi-host network but launched from different Engines can
63       also communicate in this way.
64
65
66       You can connect a container to one or more networks. The networks need
67       not be the same type. For example, you can connect a single container
68       bridge and overlay networks.
69
70
71

OPTIONS

73       NETWORK
74         Specify network name
75
76
77       CONTAINER
78         Specify container name
79
80
81       --help
82         Print usage statement
83
84
85

HISTORY

87       OCT 2015, created by Mary Anthony ⟨mary@docker.com⟩
88
89
90
91Docker Community              Docker User Manuals                    DOCKER(1)
Impressum