Skip to main content

CV-M003: Undefined network reference

Error Semantic

Why This Matters

A service references a network that is not defined in the top-level networks section. Docker Compose will fail to start with an error when a service references an undefined network. Either add the network to the top-level networks section or fix the network name in the service definition. The implicit "default" network does not need to be declared.

How to Fix

Define the referenced network in the top-level networks section.

Before (incorrect)

services:
  web:
    networks:
      - backend
# No top-level networks defined

After (correct)

services:
  web:
    networks:
      - backend
networks:
  backend:

Rule Details

Rule Code
CV-M003
Severity
Error
Category
Semantic

Related Rules