compose-lint
Community plugin: Plugins are maintained by their community authors, not by the MegaLinter team. Using a plugin means trusting its author. This plugin is maintained by Todd Matens: report its problems on its repository, not to MegaLinter.
Security linter for Docker Compose files (COMPOSE_COMPOSE_LINT)
- Documentation: https://tmatens.github.io/compose-lint/megalinter/
- Descriptor: https://raw.githubusercontent.com/tmatens/compose-lint/main/mega-linter-plugin-compose-lint/compose-lint.megalinter-descriptor.yml
- Maintainer: Todd Matens
⚠️ Required items are missing in this plugin (native mode): see MegaLinter checks.
compose-lint is a security linter for Docker Compose files. It reports dangerous settings in 'compose.yml' / 'docker-compose.yml' files, with the fix for each finding and a reference to the OWASP Docker Security Cheat Sheet or the CIS Docker Benchmark.
The build fails on 'high' and 'critical' findings by default. Lower severities are reported without failing.
compose-lint does not validate the Compose schema, lint Dockerfiles or scan images for vulnerabilities.
compose-lint documentation
- Visit Official Web Site
- See How to configure compose-lint rules
- See How to ignore files and directories with compose-lint
- See Index of problems detected by compose-lint
Configuration in MegaLinter
- Enable compose-lint by adding
COMPOSE_COMPOSE_LINTin ENABLE_LINTERS variable - Disable compose-lint by adding
COMPOSE_COMPOSE_LINTin DISABLE_LINTERS variable
| Variable | Description | Default value |
|---|---|---|
| COMPOSE_COMPOSE_LINT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
| COMPOSE_COMPOSE_LINT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
| COMPOSE_COMPOSE_LINT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Exclude no file |
| COMPOSE_COMPOSE_LINT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
| COMPOSE_COMPOSE_LINT_CLI_LINT_MODE | Override default CLI lint mode - file: Calls the linter for each file- list_of_files: Call the linter with the list of files as argument |
list_of_files |
| COMPOSE_COMPOSE_LINT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
Exclude every file |
| COMPOSE_COMPOSE_LINT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
["(docker-)?compose(\\.[\\w.-]+)?\\.ya?ml"] |
| COMPOSE_COMPOSE_LINT_PRE_COMMANDS | List of bash commands to run before the linter | None |
| COMPOSE_COMPOSE_LINT_POST_COMMANDS | List of bash commands to run after the linter | None |
| COMPOSE_COMPOSE_LINT_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling COMPOSE_COMPOSE_LINT and its pre/post commands | None |
| COMPOSE_COMPOSE_LINT_CONFIG_FILE | compose-lint configuration file nameUse LINTER_DEFAULT to let the linter find it |
.compose-lint.yml |
| COMPOSE_COMPOSE_LINT_RULES_PATH | Path where to find linter configuration file | Workspace folder |
| COMPOSE_COMPOSE_LINT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
| COMPOSE_COMPOSE_LINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
| COMPOSE_COMPOSE_LINT_TIMEOUT_SECONDS | Maximum duration in seconds of the linter run, after which the linter process and its child processes are killed and reported as an error (exit code 124). Overrides LINTER_TIMEOUT_SECONDS. 0 disables the timeout | 300 |
| COMPOSE_COMPOSE_LINT_CLI_EXECUTABLE | Override CLI executable | ['compose-lint'] |
Use this plugin
Add the descriptor URL of the plugin to PLUGINS in .mega-linter.yml. MegaLinter installs the plugin when it starts, whatever the flavor:
PLUGINS:
- https://raw.githubusercontent.com/tmatens/compose-lint/main/mega-linter-plugin-compose-lint/compose-lint.megalinter-descriptor.yml
Behind the scenes
How are identified applicable files
- File names (regex):
(docker-)?compose(\.[\w.-]+)?\.ya?ml
How the linting is performed
- compose-lint is called once with the list of files as arguments (
list_of_filesCLI lint mode)
Example calls
compose-lint check -- compose.yml
compose-lint check --config .compose-lint.yml -- compose.yml docker-compose.prod.yml
compose-lint check --format sarif -- compose.yml
Installation in Docker
MegaLinter runs these commands when it loads the plugin (only RUN instructions):
RUN python3 -m venv /venvs/compose-lint && \
/venvs/compose-lint/bin/pip install --no-cache-dir "compose-lint==1.9.0" && \
ln -sf /venvs/compose-lint/bin/compose-lint /usr/local/bin/compose-lint
Installation without Docker (native mode)
Native mode does not run plugins yet: this section shows what the plugin declares for native mode.
Not available: see the MegaLinter checks of the plugin.
Known errors and resolutions
When this linter fails for a known non-lint reason (remote service unavailable, malformed config, missing credentials, etc.), MegaLinter detects the pattern below in the linter output and surfaces the matching guidance.
COMPOSE_COMPOSE_LINT_ERROR_COVERAGE_GAP
Detection pattern (regex):
pass --allow-partial-coverage to accept it
Resolution guidance:
compose-lint could not read part of the stack (for example an unresolved 'include:' or cross-file 'extends:'), so it reported an error instead of grading a partial view. Correct the reference named in the message above, or accept the gap in your .mega-linter.yml: COMPOSE_COMPOSE_LINT_ARGUMENTS: ["--allow-partial-coverage"]
MegaLinter checks
These results last changed on 2026-11-29, and MegaLinter checks the plugins every day. The checks only look at the descriptor of the plugin: they do not review the plugin, nor the tool it runs.
| Check | Result |
|---|---|
| Descriptor | ⚠️ Incomplete |
| Native mode | ❌ Not supported |
| SARIF output | ✅ |
| Native lock | ⚠️ No lock shipped by the plugin author |
Required
Missing required items:
native_installdeclared and valid for the 5 native platforms (COMPOSE_COMPOSE_LINT): Native mode (MegaLinter without Docker) can not install the linter. Declarenative_install, listing each of linux/amd64, linux/arm64, darwin/amd64, darwin/arm64 and windows/amd64 inplatformsor inunsupported(with a reason)
Recommended
Missing recommended items:
- Native lock shipped next to the descriptor (
<name>.megalinter-native-lock.json), for verified native installs - Inline disable documentation URL (
linter_rules_inline_disable_url) (COMPOSE_COMPOSE_LINT) - Speed (
linter_speed, 1 to 5) (COMPOSE_COMPOSE_LINT) - Icon (
linter_icon_png_url) (COMPOSE_COMPOSE_LINT) - IDE extensions (
ide) (COMPOSE_COMPOSE_LINT) - Test fixtures (
test_folder) (COMPOSE_COMPOSE_LINT)
Plugin authors
The requirements and how to fix them are described in Create your own plugin.