docker-network
Manage Docker networks
TLDR
List all available and configured networks on Docker daemon
Create a user-defined network
Display detailed information about one or more networks
Connect a container to a network using a name or ID
Disconnect a container from a network
Remove all unused (not referenced by any container) networks
Remove one or more unused networks
SYNOPSIS
docker network [OPTIONS] COMMAND
PARAMETERS
create
Create a network.
Options include:
-d, --driver: Network driver to use (default "bridge")
--gateway: IPv4 or IPv6 Gateway for the master subnet
--ingress: Create swarm routing-mesh network
--ip-range: Allocate container IP addresses from a sub-range
--ipam-driver: IP Address Management Driver
--ipam-opt: Set IPAM driver specific options
--ipv6: Enable IPv6 networking
--label: Set metadata on a network
-o, --opt: Set driver specific options
--scope: Control the network’s scope (default "local")
connect
Connect a container to a network.
Options include:
--alias: Add network alias
--driver-opt: Driver options for the network connection
--ip: IPv4 address (e.g., 172.20.0.2)
--ip6: IPv6 address (e.g., 2001:db8::33)
--link: Add link to another container
disconnect
Disconnect a container from a network.
Options include:
-f, --force: Force the container to disconnect from a network
inspect
Display detailed information on one or more networks.
Options include:
-f, --format: Go template to format the output
--verbose: Show all settings
ls
List networks.
Options include:
-f, --filter: Filter output based on conditions provided
--format: Go template to format the output
-q, --quiet: Only display numeric IDs
prune
Remove all unused networks.
Options include:
-f, --force: Do not prompt for confirmation
rm
Remove one or more networks.
DESCRIPTION
The `docker network` command in Linux is a powerful tool for managing Docker networks. It allows you to create, inspect, connect containers to, and disconnect containers from Docker networks. These networks provide isolated environments for containers to communicate with each other, enhancing security and simplifying service discovery. Different network drivers like `bridge`, `host`, `overlay`, and `macvlan` are supported, enabling various networking configurations. By default, Docker creates a `bridge` network named `bridge` (also known as `docker0`). Users can create custom networks tailored to their application's needs. The `docker network` command is essential for building complex, multi-container applications that require structured communication. You can use it to isolate different parts of your application into separate networks, or to connect specific containers to external networks for specific purposes. Understanding Docker networking is crucial for effectively deploying and managing containerized applications.
CAVEATS
Removing a network that is currently in use by a container will result in an error. Containers must be stopped or disconnected from the network before it can be removed.
NETWORK DRIVERS
bridge: Default network driver. Containers on the same bridge network can communicate.
host: Uses the host's networking directly; containers share the host's network namespace.
overlay: Enables communication between containers running on different Docker hosts; used for Docker Swarm services.
macvlan: Assigns a MAC address to each container's virtual network interface, making containers appear as physical devices on the network.
none: Containers are isolated and not connected to any network.
SEE ALSO
docker(1), docker-compose(1), iptables(8)