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
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
docker compose
Manages multi-container applications defined in a compose.yaml file. This is the Compose V2 plugin invoked via 'docker compose' (space); the legacy hyphenated 'docker-compose' binary is deprecated.
docker inspect
Returns low-level JSON metadata about Docker objects — containers, images, networks, volumes, and more. Supports Go template formatting for extracting specific fields.
docker volume
Manages persistent named volumes for containers — create, list, inspect, remove, and prune. Named volumes survive container removal and are the recommended storage mechanism over bind mounts for stateful data.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs