Skip to main content

CV-M007: Orphan network definition

Warning Semantic

Why This Matters

A network is defined in the top-level networks section but is not referenced by any service. Orphan network definitions add unnecessary clutter and Docker will create the network even though nothing uses it, wasting resources. Remove unused networks or add them to the appropriate services.

How to Fix

Remove the unused network or add it to a service.

Before (incorrect)

services:
  web:
    image: nginx
networks:
  frontend:
  backend:

After (correct)

services:
  web:
    image: nginx
    networks:
      - frontend
networks:
  frontend:

Rule Details

Rule Code
CV-M007
Severity
Warning
Category
Semantic

Related Rules