Docker Compose security and best-practice linter
Project description
compose-auditor
Docker Compose security and best-practice linter. Catches common misconfigs, security issues, and operational gaps before they reach production.
Install
# From source (recommended for local use)
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# Or directly into a venv
pip install compose-auditor
Usage
# Basic lint — colored text output, exits 1 on CRITICAL
compose-auditor lint docker-compose.yml
# Lint a specific path
compose-auditor lint ~/Media/docker-compose.yml
# JSON output (for CI pipelines)
compose-auditor lint docker-compose.yml --format json
# Control exit behavior
compose-auditor lint docker-compose.yml --fail-on warning # exit 1 on WARNING+
compose-auditor lint docker-compose.yml --fail-on never # always exit 0
# No color (for logs)
compose-auditor lint docker-compose.yml --no-color
# Homelab profile — suppresses noisy rules irrelevant to personal stacks
compose-auditor lint docker-compose.yml --profile homelab
# Ignore specific rules (repeatable)
compose-auditor lint docker-compose.yml --ignore SEC002 --ignore VOL001
# Use a config file explicitly
compose-auditor lint docker-compose.yml --config .compose-auditor.yml
Profiles
Profiles adjust severity for context. The homelab profile is built-in and tuned for personal self-hosted stacks.
| Rule | Default | homelab |
|---|---|---|
| VOL001 | INFO | suppressed |
| RES002 | INFO | suppressed |
| OPS003 | INFO | suppressed |
| NET002 | WARNING | INFO |
| IMG001 | WARNING | INFO |
| RES001 | WARNING | INFO |
Config File
Auto-discovered from .compose-auditor.yml in the current directory, then the home directory. Override with --config.
# .compose-auditor.yml
profile: homelab
ignore:
- OPS003 # global — suppressed for all services
rules:
NET002: INFO # downgrade globally
services:
traefik:
ignore:
- NET001 # traefik legitimately uses host networking
db:
ignore:
- SEC002 # postgres image sets its own user
Supported keys:
profile— apply a named profile (homelab)ignore— list of rule IDs to suppress globallyrules— map of rule ID → new severity (CRITICAL,WARNING,INFO)services.<name>.ignore— per-service rule suppression
LSIO Auto-Detection
SEC002 (running as root / no user directive) is automatically suppressed for LinuxServer.io images. These images manage their own user mapping via PUID/PGID environment variables.
Matched prefixes:
lscr.io/linuxserver/linuxserver/ghcr.io/linuxserver/
Rules
| Rule ID | Severity | Description |
|---|---|---|
| SEC001 | CRITICAL | Privileged container |
| SEC002 | CRITICAL/WARNING | Running as root or no user directive |
| SEC003 | CRITICAL | Docker socket mounted |
| SEC004 | WARNING | Bind mount to sensitive host path (/etc, /proc, /sys, etc.) |
| SEC005 | CRITICAL | Plain-text secrets in environment variables |
| NET001 | CRITICAL | Host network mode |
| NET002 | WARNING | Port bound to 0.0.0.0 (all interfaces) |
| NET003 | CRITICAL | Duplicate host port binding across services |
| OPS001 | INFO | No restart policy |
| OPS002 | INFO/WARNING | No healthcheck or healthcheck disabled |
| OPS003 | INFO | No logging configuration |
| RES001 | WARNING | No memory limit |
| RES002 | INFO | No CPU limit |
| IMG001 | WARNING | Using :latest (or untagged) image |
| VOL001 | INFO | Volume mounted read-write (consider :ro) |
| DEP001 | INFO | Service referenced in env/links without depends_on |
NET003 is protocol-aware — TCP and UDP bindings on the same port number are treated as distinct and do not trigger a false positive.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | No issues at or above --fail-on threshold |
| 1 | One or more findings at or above threshold |
| 2 | Parse error (invalid YAML or not a compose file) |
JSON Output Schema
{
"file": "/path/to/docker-compose.yml",
"summary": {
"CRITICAL": 3,
"WARNING": 7,
"INFO": 12
},
"findings": [
{
"severity": "CRITICAL",
"rule_id": "SEC001",
"service": "web",
"message": "Container runs in privileged mode",
"detail": "..."
}
]
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compose_auditor-0.2.0.tar.gz.
File metadata
- Download URL: compose_auditor-0.2.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1be28766fbf973b1bd34963d6ffa42b672bcca5a249aaa19467f935fc5bccdf
|
|
| MD5 |
c04395f58a5016b9873de9684d60f96b
|
|
| BLAKE2b-256 |
7d2ade4c452d9c333581686e2092c0b5afa89721df4ea1141f83d1b5f9d013e1
|
File details
Details for the file compose_auditor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: compose_auditor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a26b5ed5bc3cdbec015cc2e218e70cfd2053c5863b2da954cd11fce5e5212f5
|
|
| MD5 |
e96a14dd3bfe1c06ae39e8f74352f090
|
|
| BLAKE2b-256 |
4f1409951e371d1af8c5d788dd389e9d011d574e585774edf618f6603aa44cf8
|