Skip to content
DashboardWebsite

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.

A diff file reaches this pack in two ways:

  1. By path. The file matches one of these globs: *docker-compose*.yml, *docker-compose*.yaml, *compose.yml, *compose.yaml, *compose.*.yml, *compose.*.yaml.
  2. 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 apiVersion or kind;
  • GitLab CI files with a top-level stages, workflow, before_script or after_script, or a services: 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.

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 pathtypename
services.web...serviceweb
networks.backend...networkbackend
volumes.db-data...volumedb-data
secrets.api_key...secretapi_key
configs.nginx...confignginx
any other top-level key (name, include, x-common)top-levelthe key
a service whose name line is above the hunkserviceunknown

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.

Markers present in the unitaction
+ onlyadd
- onlydelete
bothmodify

body keeps its +, - and space prefixes, so a rule can tell an added privileged: true from one that was already there.

{
"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.

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 IDAreaWhat it catches
DC-001Privilege and host accessprivileged: true
DC-002Privilege and host accessnetwork_mode, pid or ipc set to host
DC-003Privilege and host accessThe Docker or Podman socket mounted
DC-004Privilege and host accessA bind mount of /, /etc or another host system path
DC-005Privilege and host accesscap_add outside the approved list; SYS_ADMIN or ALL is CRITICAL
DC-006Privilege and host accesssecurity_opt disables confinement, including unconfined seccomp or AppArmor
DC-007Public exposureA database, broker or admin port published with no host IP
DC-008SecretsA literal secret in environment or a variable default
DC-009Image and build complianceA mutable or untagged image without a digest, or an image moved to another registry
DC-010Privilege and host accessuser: root or a numeric root user
DC-011Privilege and host accessread_only, cap_drop or security_opt hardening removed or weakened
DC-012Image and build complianceA build context widened to a parent directory or a Dockerfile outside the context
DC-PERF-001 to -003PerformanceUnbounded json-file logs, a frequent expensive healthcheck, or no memory limit
DC-REL-001 to -004Reliabilitydepends_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).

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: true

Two units come out:

  • service agent, action add. The LLM matches DC-001 and DC-002.
  • service cache, action modify. The LLM matches DC-009: a pinned tag replaced by latest.