Docker Compose Linter

Dev Tools

Lint docker-compose.yml files for security, best practices, and port conflicts.

Install

openclaw skills install docker-compose-linter

docker-compose-linter

A pure Python 3 (stdlib only) linter for docker-compose.yml files.

Commands

python3 scripts/docker-compose-linter.py <command> [options] FILE
CommandDescription
lintLint a docker-compose.yml for issues
servicesList all services with their images/builds
portsList all port mappings, detect conflicts
auditFull audit (lint + services + ports summary)

Options

OptionDescription
--format text|json|markdownOutput format (default: text)
--strictExit 1 on any issue (not just errors)
--ignore RULEIgnore a specific rule (repeatable)
--min-severity error|warning|infoMinimum severity to report (default: info)

Lint Rules

RuleSeverityDescription
no-versioninfoMissing or outdated version: key
no-healthcheckwarningService without healthcheck defined
no-restart-policywarningService without restart policy
privileged-modeerrorService running in privileged mode
port-conflicterrorMultiple services mapping to same host port
host-networkwarningUsing network_mode: host (security risk)
latest-tagwarningImage using :latest tag or no tag
no-resource-limitsinfoNo memory/CPU limits (deploy.resources)
hardcoded-envwarningSecrets/passwords directly in environment variables
root-userwarningNo user: specified (runs as root by default)
missing-depends-oninfoService uses links but no depends_on
bind-mount-relativeinfoRelative bind mount paths
no-logginginfoNo logging configuration
duplicate-serviceerrorDuplicate service names

Examples

# Lint with default text output
python3 scripts/docker-compose-linter.py lint docker-compose.yml

# Only show errors and warnings
python3 scripts/docker-compose-linter.py --min-severity warning lint docker-compose.yml

# JSON output for CI pipelines
python3 scripts/docker-compose-linter.py --format json lint docker-compose.yml

# Full audit in markdown
python3 scripts/docker-compose-linter.py --format markdown audit docker-compose.yml

# Ignore specific rules
python3 scripts/docker-compose-linter.py --ignore root-user --ignore no-logging lint docker-compose.yml

# Strict mode: exit 1 on any issue
python3 scripts/docker-compose-linter.py --strict lint docker-compose.yml

Requirements

  • Python 3.7+
  • No external dependencies (pure stdlib)