How to List Networks in Docker: Syntax and Examples
Use the
docker network ls command to list all networks in Docker. This command shows network IDs, names, drivers, and scope for each network.Syntax
The basic command to list Docker networks is docker network ls. It shows all networks available on your Docker host.
docker: The Docker command-line tool.network: The Docker subcommand to manage networks.ls: Lists all networks.
bash
docker network ls
Example
This example runs the command to list all Docker networks and shows typical output. It helps you see network names, IDs, drivers, and scopes.
bash
docker network ls
Output
NETWORK ID NAME DRIVER SCOPE
b1a2c3d4e5f6 bridge bridge local
c7d8e9f0a1b2 host host local
d3e4f5a6b7c8 none null local
Common Pitfalls
Some common mistakes when listing Docker networks include:
- Running
docker network lswithout Docker running or without proper permissions, which causes errors. - Expecting to see networks from remote Docker hosts; this command only lists local networks.
- Confusing network names with container names.
Always ensure Docker daemon is running and you have the right permissions.
bash
docker network ls # Wrong: Running without Docker daemon # Output: error during connect: This error may indicate that the docker daemon is not running. # Correct: Start Docker daemon first sudo systemctl start docker docker network ls
Quick Reference
| Command | Description |
|---|---|
| docker network ls | List all Docker networks |
| docker network inspect | Show detailed info about a specific network |
| docker network create | Create a new Docker network |
| docker network rm | Remove a Docker network |
Key Takeaways
Use
docker network ls to list all Docker networks on your local machine.Ensure the Docker daemon is running before listing networks to avoid connection errors.
The command shows network ID, name, driver type, and scope for each network.
This command only lists networks on the local Docker host, not remote hosts.
Use additional commands like
docker network inspect for detailed network info.