network

docker network

Manages Docker networks — create, inspect, connect, disconnect, and remove user-defined bridges, overlays, or macvlan networks. Enables container-to-container DNS resolution by name.

docker network COMMAND

Common flags

Flag Purpose
-d, --driver Driver to use (bridge, overlay, macvlan, host, none)
--subnet Specify the subnet CIDR when creating
--attachable Allow standalone containers to attach to an overlay network
--internal Restrict external access to the network
-f, --force Force removal (with rm subcommand)

Examples

docker network create app-net

Create a user-defined bridge network

docker network create -d overlay --attachable swarm-net

Attachable overlay for Swarm mode

docker network connect app-net web

Attach the web container to a network

docker network inspect bridge

Show subnet, gateway, and connected containers

Gotcha

The default bridge network does NOT provide DNS-based container name resolution — always create a user-defined bridge for multi-container apps. Overlay networks require Swarm mode initialized on the host.

Related commands

← All Docker commands · Docker vs Kubernetes · Docker vs VMs