LinuxCommandLibrary

docker-network

Manage Docker networks

TLDR

List all available and configured networks on Docker daemon

$ docker network ls
copy

Create a user-defined network
$ docker network create [[-d|--driver]] [driver_name] [network_name]
copy

Display detailed information about one or more networks
$ docker network inspect [network_name1 network_name2 ...]
copy

Connect a container to a network using a name or ID
$ docker network connect [network_name] [container_name|ID]
copy

Disconnect a container from a network
$ docker network disconnect [network_name] [container_name|ID]
copy

Remove all unused (not referenced by any container) networks
$ docker network prune
copy

Remove one or more unused networks
$ docker network rm [network_name1 network_name2 ...]
copy

SYNOPSIS

docker network COMMAND [OPTIONS]

Commands:
connect Connect container to network
create Create network
disconnect Disconnect container from network
inspect Inspect network(s)
ls List networks
prune Prune unused networks
rm Remove network(s)

PARAMETERS

--debug
    Enable debug mode

--help
    Print usage

-v, --verbose
    Enable verbose output

--version
    Print version information

DESCRIPTION

The docker network command manages networks for Docker containers, enabling isolated communication between containers, the host, or external networks.

Docker networks abstract connectivity, supporting drivers like bridge (default, single-host), overlay (multi-host/Swarm), host (shares host network), none (no network), macvlan, and ipvlan. Custom networks provide automatic DNS resolution using container names, improved isolation, and scalability for microservices.

Key uses include Docker Compose multi-container apps and Docker Swarm services. Subcommands handle creation, listing, inspection, connection/disconnection of containers to networks, removal, and pruning unused ones. Essential for secure, efficient container orchestration without manual iptables rules.

CAVEATS

Default networks (bridge, host, none) cannot be removed. Networks must have no connected containers to delete. Use docker network inspect to check usage.

NETWORK DRIVERS

bridge: Default single-host.
overlay: Multi-host, VXLAN encrypted.
host: No isolation.
none: Disable networking.
macvlan/ipvlan: L2/L3 host-like IPs.

HISTORY

Introduced in Docker 1.9.0 (November 2015) with libnetwork and Container Network Model (CNM). Evolved for Swarm mode in Docker 1.12+; drivers expanded in later releases for Kubernetes compatibility via plugins.

SEE ALSO

docker(1), docker-container(1), docker-network-create(1), docker-network-ls(1), bridge(8)

Copied to clipboard