.nh
.TH "DOCKER" "1" "Jun 2026" "Docker Community" "Docker User Manuals"

.SH NAME
docker-network-connect - Connect a container to a network


.SH SYNOPSIS
\fBdocker network connect [OPTIONS] NETWORK CONTAINER\fP


.SH DESCRIPTION
Connects a 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.

.EX
$ docker network connect multi-host-network container1
.EE

.PP
You can also use the \fBdocker run --network=<network-name>\fR option to start a container and immediately connect it to a network.

.EX
$ docker run -itd --network=multi-host-network --ip 172.20.88.22 --ip6 2001:db8::8822 busybox
.EE

.PP
You can pause, restart, and stop containers that are connected to a network.
A container connects to its configured networks when it runs.

.PP
If specified, the container's IP address(es) is reapplied when a stopped
container is restarted. If the IP address is no longer available, the container
fails to start. One way to guarantee that the IP address is available is
to specify an \fB--ip-range\fR when creating the network, and choose the static IP
address(es) from outside that range. This ensures that the IP address is not
given to another container while this container is not on the network.

.EX
$ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network

$ docker network connect --ip 172.20.128.2 multi-host-network container2
.EE

.PP
To verify the container is connected, use the \fBdocker network inspect\fR command. Use \fBdocker network disconnect\fR to remove a container from the network.

.PP
Once connected in network, containers can communicate using only another
container's IP address or name. For \fBoverlay\fR 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.

.PP
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.


.SH OPTIONS
\fB--alias\fP=[]
	Add network-scoped alias for the container

.PP
\fB--driver-opt\fP=[]
	driver options for the network

.PP
\fB--gw-priority\fP=0
	Highest gw-priority provides the default gateway. Accepts positive and negative values.

.PP
\fB--ip\fP=
	IPv4 address (e.g., "172.30.100.104")

.PP
\fB--ip6\fP=
	IPv6 address (e.g., "2001:db8::33")

.PP
\fB--link\fP=
	Add link to another container

.PP
\fB--link-local-ip\fP=[]
	Add a link-local address for the container


.SH SEE ALSO
\fBdocker-network(1)\fP
