Identifying and Listing Unused Docker Networks
To identify and list unused Docker networks, you can use the following Docker CLI commands:
Listing All Docker Networks
To list all the Docker networks on your system, you can use the docker network ls
command:
docker network ls
This will output a table with the following columns:
- NETWORK ID
- NAME
- DRIVER
- SCOPE
Identifying Unused Docker Networks
To identify unused Docker networks, you can use the docker network ls
command with the -f
(filter) option:
docker network ls -f "dangling=true"
This will list all the Docker networks that are not being used by any containers. The dangling=true
filter ensures that only the networks without any connected containers are displayed.
Alternatively, you can use the following command to list all the networks that are not being used by any running containers:
docker network ls --filter "scope=local" --filter "driver=bridge" --filter "name=^((?!host|none|bridge).)*$" --format "{{.ID}}\t{{.Name}}\t{{.Driver}}"
This command filters the network list to show only the local, bridge-based networks that are not the default host
, none
, or bridge
networks.
The output of this command will be a table with the following columns:
By using these commands, you can easily identify and list the unused Docker networks on your system, which can be useful for cleaning up your Docker environment.