CodeBlanks Logo Icon CodeBlanks

docker network ls

Learn to list networks with docker network ls.

docker network ls

Docker creates three networks with the installation: bridge, host and none. docker network ls lists them and the ones you created:

$ docker network ls
NETWORK ID     NAME            DRIVER    SCOPE
1a2b3c4d5e6f   bridge          bridge    local
2b3c4d5e6f70   host            host      local
3c4d5e6f7081   none            null      local
4d5e6f708192   proje_default   bridge    local

Inspecting a network

docker network inspect shows the network's subnet, gateway and connected containers with their IP addresses:

$ docker network inspect -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' bridge
172.17.0.0/16
$ docker network inspect -f '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{"\n"}}{{end}}' proje_default
proje-db-1 172.18.0.2/16
proje-api-1 172.18.0.3/16

Practice Explore the networks

Write two commands: list only the networks with the bridge driver (--filter driver=bridge); then print the subnet of the bridge network with the {{range .IPAM.Config}}{{.Subnet}}{{end}} template.

Starter code

terminal
# buraya yaz

Sample solution

terminal
docker network ls --filter driver=bridge
docker network inspect -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' bridge

Expected output

NETWORK ID     NAME            DRIVER    SCOPE
1a2b3c4d5e6f   bridge          bridge    local
4d5e6f708192   proje_default   bridge    local
172.17.0.0/16

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Who created the proje_default network?

  • The Docker installation
  • The operating system
  • Kubernetes
  • Docker Compose, for the project folder Correct answer

Explanation: Compose creates a name_default network for each project.

2 Show the network's details.

Question
docker network ____ bridge
Answer
docker network inspect bridge

Explanation: inspect gives the subnet and connected containers.

3 Match.

Term Meaning
network ls List networks
network inspect Details
172.17.0.0/16 Default bridge subnet
SCOPE local Single-host network

All lessons in Beginner