Docker Certified Associate Exam Course

Docker Engine Networking

Networking additional commands

Manage Docker networks beyond the basics. In this guide, you’ll learn how to list default networks, inspect their settings, connect or disconnect containers, and remove unused networks to keep your Docker environment clean.

Table of Contents


Listing Default Networks

Docker provides three built-in networks out of the box: bridge, host, and none. Use the following command to see them:

docker network ls

Example output:

NETWORK ID          NAME      DRIVER    SCOPE
599dcaf4e856        bridge    bridge    local
c817f1bca596        host      host      local
e6508d3404a3        none      null      local

You can also get a quick overview in tabular form:

Network NameDriverScopeDescription
bridgebridgelocalDefault network for standalone containers
hosthostlocalContainers share the host’s network namespace
nonenulllocalContainers have no network interfaces

Note

The bridge network uses the 172.17.0.0/16 subnet by default, with gateway 172.17.0.1 assigned to the docker0 interface on the host.


Inspecting a Network

To dive deeper into a network’s configuration—such as its IPAM settings, subnets, gateways, and attached containers—run:

docker network inspect bridge

Sample output (abridged):

[
  {
    "Name": "bridge",
    "Id": "599dcaf4e85648c3a111baa52b7530f097853b96485a8a3ffcd9088b20f0cb",
    "Scope": "local",
    "Driver": "bridge",
    "IPAM": {
      "Driver": "default",
      "Config": [
        {
          "Subnet": "172.17.0.0/16",
          "Gateway": "172.17.0.1"
        }
      ]
    },
    "Containers": {
      // attached container details
    }
  }
]

This output shows the network’s driver, IPAM configuration, and any containers currently connected.


Connecting and Disconnecting Containers

You can attach a running container to additional networks or remove it from one without restarting:

# Connect a container to a custom network
docker network connect custom-net my-container

# Disconnect a container from a network
docker network disconnect custom-net my-container

These commands make it easy to adjust a container’s network access on the fly.


Removing Networks

Clean up unused networks to avoid clutter:

# Remove a specific network
docker network rm custom-net

# Remove all unused networks
docker network prune

Warning

This will remove all networks not used by at least one container.
Are you sure you want to continue? [y/N]


Watch Video

Watch video content

Previous
Docker Networking