Inspecting the Default Bridge Network
Now that we've seen the list of networks, let's take a closer look at the default bridge network. This network is created automatically by Docker and is used by containers unless specified otherwise.
Run the following command to inspect the bridge network:
docker network inspect bridge
This command provides detailed information about the bridge network, including its subnet, gateway, and connected containers. You'll see output similar to this (truncated for brevity):
[
{
"Name": "bridge",
"Id": "79dce413aafdd7934fa3c1d0cc97decb823891ce406442b7d51be6126ef06a5e",
"Created": "2024-08-22T09:58:39.747333789+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Let's break down some key information from this output:
Subnet
: The subnet used by containers in this network is 172.17.0.0/16
. This means containers will be assigned IP addresses within this range.
Gateway
: The gateway for this network is 172.17.0.1
. This is the IP address that containers use to communicate with networks outside their own.
Containers
: This field is empty because we haven't started any containers yet.
Options
: These are various configuration options for the bridge network. For example, enable_icc
set to "true" means that inter-container communication is allowed on this network.
Understanding this information is crucial when troubleshooting network issues or when you need to configure your containers to communicate with specific IP ranges.