Command
docker network rmExplanation
docker network rm removes specified networks by name or ID. Networks in use by containers cannot be deleted. docker network prune removes all unused networks automatically.
Common Use Cases
- •Clean up old or unused networks
- •Recreate network with updated configuration
Best Practices
- ✓Remove unused networks regularly
- ✓Use docker network prune carefully to avoid deleting shared networks
Common Mistakes to Avoid
- ⚠Trying to delete networks still in use by containers
Troubleshooting
Problem: Error: network in use
Solution: Stop or disconnect all containers attached to the network before removal.
Examples
Remove a single network
docker network rm mynetRemove all unused networks
docker network prune