docker network rm: Remove Networks & In-Use Errors
Remove a user-defined network once nothing is attached.
docker network rm deletes networks. This page covers the active-endpoints error and how prune differs.
What it does
docker network rm removes one or more user-defined networks. A network with connected containers cannot be removed until they disconnect or stop.
Common usage
Terminal
docker network rm testnet
docker network prune -f # remove all unused networksCommon errors in CI
"error while removing network: network ... has active endpoints" means a container is still attached - stop/remove it first, then rm the network. You cannot remove the built-in bridge, host, or none. For bulk cleanup of leftover compose networks, docker network prune -f is simpler than individual rm.
Related guides
docker network create: Create User-Defined NetworksHow docker network create works: creating bridge networks for container DNS, drivers and subnets, and connect…
docker network ls: List Docker NetworksHow docker network ls works: listing networks, the default bridge/host/none, filtering, and debugging connect…
docker system prune: Reclaim Disk in CIHow docker system prune works: removing stopped containers, unused networks, dangling images, and build cache…
docker compose down: Tear Down a Compose StackHow docker compose down works: stopping and removing services, networks, and volumes, the -v flag, and clean…