Skip to main content

CV-M008: Orphan volume definition

Warning Semantic

Why This Matters

A volume is defined in the top-level volumes section but is not referenced by any service. Orphan volume definitions cause Docker to create empty volumes that consume disk space and add clutter. Remove unused volumes or mount them in the appropriate services.

How to Fix

Remove the unused volume or mount it in a service.

Before (incorrect)

services:
  db:
    image: postgres
volumes:
  pgdata:
  cache:

After (correct)

services:
  db:
    image: postgres
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:

Rule Details

Rule Code
CV-M008
Severity
Warning
Category
Semantic

Related Rules