Listing Default Networks
Docker comes with three built-in networks:
To see these networks:
Inspecting the Bridge Network
To view details such as subnet configuration and gateway:The IPAM (IP Address Management) section shows how Docker assigns subnets and gateways.
Running Containers on the Default Bridge
When you start a container without specifying a network, it’s attached tobridge:
Creating a User-Defined Bridge Network
User-defined bridge networks include built-in DNS and automatic name resolution. Create one with a custom subnet:Running Containers on the Custom Network
Launch two containers onkodekloudnet:
192.168.10.0/24, and DNS-based name resolution works:
Connecting an Existing Container to a Network
By default, containers attach only to the default bridge. To connectfirst to kodekloudnet:
first from customfirst:
Disconnecting a Container from a Network
To detach a container:customfirst will no longer reach first on that network.
Removing Networks
Docker prevents removing networks with active endpoints. To deletekodekloudnet:
- Stop and remove containers:
- Remove the network:
docker network prune removes only user-defined networks without active containers. Default networks (bridge, host, none) are not affected.