Docker Compose Pack
URL slug: docker-compose
Reviews changes to Docker Compose files. Each changed service or top-level entry becomes its own analysis unit. The pack can catch a service that turns privileged, mounts the Docker socket, or publishes a database port on every host interface.
Which files it reads
Section titled “Which files it reads”A diff file reaches this pack in two ways:
- By path. The file matches one of these globs:
*docker-compose*.yml,*docker-compose*.yaml,*compose.yml,*compose.yaml,*compose.*.yml,*compose.*.yaml. - By content. The file path does not match one of this pack’s globs, and its added lines look like Compose.
The pack overrides sniff(). It returns 0.8 when the text has a top-level services:
mapping and at least one entry sets image: to a name or has a build: key. It returns 0.0
otherwise. This excludes:
- Kubernetes manifests with a top-level
apiVersionorkind; - GitLab CI files with a top-level
stages,workflow,before_scriptorafter_script, or aservices:list; - Helm values files, where
image:is usually a mapping, not a name; - Ansible playbooks, which are lists of plays.
A pasted Compose file with no diff --git header is accepted too. Every line counts as added.
How it splits changes into units
Section titled “How it splits changes into units”parse_compose (src/opentremor_pack_docker_compose/parser.py) reads diff hunks with core’s
iter_hunks and finds changed blocks with core’s YAML helper, iter_yaml_blocks
(opentremor_core.libs.yaml_diff). The first two segments of a block’s key path choose its unit:
| Key path | type | name |
|---|---|---|
services.web... | service | web |
networks.backend... | network | backend |
volumes.db-data... | volume | db-data |
secrets.api_key... | secret | api_key |
configs.nginx... | config | nginx |
any other top-level key (name, include, x-common) | top-level | the key |
| a service whose name line is above the hunk | service | unknown |
Blocks for the same unit in one hunk form one unit. When they follow one another, unchanged lines between them stay in the body. When a new file adds a whole section, the pack includes the section key with the unit for its first entry.
How diff markers set the action
Section titled “How diff markers set the action”| Markers present in the unit | action |
|---|---|
+ only | add |
- only | delete |
| both | modify |
body keeps its +, - and space prefixes, so a rule can tell an added privileged: true from
one that was already there.
Unit shape
Section titled “Unit shape”{ "hash": "<sha256 of the normalised body>", "type": "service", "name": "agent", "action": "modify", "body": "+ privileged: true\n+ network_mode: host", "metadata": { "generated_at_utc": "2026-10-26T10:30:00Z", "source_path": "compose.yaml", "group_path": null }}source_path is the file path from the diff header, or null for a pasted file.
group_path is always null.
Rulesets
Section titled “Rulesets”The pack’s default ruleset lives in opentremor_pack_docker_compose/rules/docker-compose-rules.md.
In the API, retrieve it with GET /v1/docker-compose/rules. This pack has one default ruleset and
no named variants.
| Rule ID | Area | What it catches |
|---|---|---|
| DC-001 | Privilege and host access | privileged: true |
| DC-002 | Privilege and host access | network_mode, pid or ipc set to host |
| DC-003 | Privilege and host access | The Docker or Podman socket mounted |
| DC-004 | Privilege and host access | A bind mount of /, /etc or another host system path |
| DC-005 | Privilege and host access | cap_add outside the approved list; SYS_ADMIN or ALL is CRITICAL |
| DC-006 | Privilege and host access | security_opt disables confinement, including unconfined seccomp or AppArmor |
| DC-007 | Public exposure | A database, broker or admin port published with no host IP |
| DC-008 | Secrets | A literal secret in environment or a variable default |
| DC-009 | Image and build compliance | A mutable or untagged image without a digest, or an image moved to another registry |
| DC-010 | Privilege and host access | user: root or a numeric root user |
| DC-011 | Privilege and host access | read_only, cap_drop or security_opt hardening removed or weakened |
| DC-012 | Image and build compliance | A build context widened to a parent directory or a Dockerfile outside the context |
| DC-PERF-001 to -003 | Performance | Unbounded json-file logs, a frequent expensive healthcheck, or no memory limit |
| DC-REL-001 to -004 | Reliability | depends_on without service_healthy, no healthcheck on a dependency, restart removed, or a named data volume lost |
Performance and Reliability rules are LOW or MEDIUM and never fail the merge check on their own.
Core keeps an organization’s unedited rules in step with this file (OpenTremor-core#0034).
Worked example
Section titled “Worked example”diff --git a/compose.yaml b/compose.yaml--- a/compose.yaml+++ b/compose.yaml@@ -1,9 +1,11 @@ services: agent: image: example/agent:2.0.1+ privileged: true+ network_mode: host restart: unless-stopped cache:- image: redis:7.2.4+ image: redis:latest read_only: trueTwo units come out:
serviceagent, actionadd. The LLM matches DC-001 and DC-002.servicecache, actionmodify. The LLM matches DC-009: a pinned tag replaced bylatest.