Free Docker Compose Security Linter (docker-compose.yml) — 18 Production Checks
Catch exposed Postgres/Redis/n8n ports on 0.0.0.0, privileged: true, /var/run/docker.sock mounts, plaintext environment secrets, and missing resilience guardrails before running docker compose up. Executes 100% locally in your browser with 0 bytes uploaded.
Interactive docker-compose.yml Security Checker (18 Rules)
100% in-browser · 0 bytes sent · < 10 msPaste any docker-compose.yml or compose.yaml below—or load the vulnerable production sample in 1 click—to get line-accurate YAML AST findings, CWE/SOC 2/ISO/DORA mappings, and IDE Quick Fixes.
.vsix locally—or unlock Pro once (no subscription) for full workspace audits, stackguard-cli, SARIF 2.1.0, and SHA-256 sealed SOC 2 / ISO 27001 / DORA reports.
All 18 Real Docker Compose Security Rules (DKR001–DKR018)
Every production check below runs on the exact YAML AST engine powering this zero-upload browser linter, the .vsix IDE extension, and stackguard-cli.
| Rule ID | Severity | Risk & Compliance Mapping | Quick Fix & Remediation |
|---|---|---|---|
DKR001Free |
HIGH |
Database, cache, or admin port exposed on 0.0.0.0
Sensitive service port (Postgres, MySQL, MongoDB, Redis, Elasticsearch, n8n, RabbitMQ, Docker API) is published on all network interfaces instead of 127.0.0.1.
|
1-Click IDE Quick Fix
Bind the port to localhost (127.0.0.1:HOST:CONTAINER) or remove public port publishing behind a TLS reverse proxy.
|
DKR002Free |
CRITICAL |
Privileged container enabled (privileged: true)
Running a container with privileged: true grants near-complete root access to the host kernel and devices.
|
1-Click IDE Quick Fix
Set privileged: false and drop unnecessary Linux capabilities.
|
DKR003Free |
CRITICAL |
Docker daemon socket (/var/run/docker.sock) mounted
Mounting /var/run/docker.sock into a container enables trivial host root takeover by spawning privileged containers.
|
Guided Remediation
Remove the docker.sock bind mount or place a strict read-only Docker socket proxy in front of it.
|
DKR004Free |
MEDIUM |
Unpinned container image tag (:latest or missing tag)
Service image uses :latest or omits a version tag/digest, breaking deterministic deployments and increasing supply-chain exposure.
|
Guided Remediation
Pin an explicit immutable version tag (e.g. postgres:16.4-alpine) or @sha256 digest.
|
DKR005Pro |
HIGH |
Host network mode enabled (network_mode: host)
network_mode: host disables Docker network namespace isolation, exposing all host loopback services to the container.
|
Guided Remediation
Use an isolated user-defined bridge network and publish only required ports.
|
DKR006Pro |
HIGH |
Dangerous Linux capability added in cap_add
Service adds high-risk Linux capabilities (ALL, SYS_ADMIN, NET_ADMIN, SYS_PTRACE, DAC_OVERRIDE, SYS_MODULE) that allow container escape.
|
Guided Remediation
Drop ALL capabilities (cap_drop: [ALL]) and add back only minimal non-privileged capabilities if strictly required.
|
DKR007Pro |
MEDIUM |
Missing healthcheck on Docker Compose service
Service does not define a healthcheck, preventing Docker and dependent services from detecting stalled processes.
|
Guided Remediation
Add a healthcheck with test, interval, timeout, and retries.
|
DKR008Pro |
MEDIUM |
Missing restart policy on Docker Compose service
Service lacks a restart policy (or sets restart: 'no'), causing downtime after host reboots or transient crashes.
|
1-Click IDE Quick Fix
Set restart: unless-stopped (or deploy.restart_policy) on production services.
|
DKR009Free |
CRITICAL |
Hardcoded secret or password in Docker Compose environment
A plaintext password, API key, or encryption key is hardcoded in service environment instead of using ${VAR} interpolation or Docker secrets.
|
1-Click IDE Quick Fix
Use ${VAR:?required} interpolation from an excluded runtime environment or Docker secrets.
|
DKR010Pro |
MEDIUM |
Container runs as root (missing non-root user directive)
Service explicitly runs as root (user: root / 0) or omits a non-root user directive, increasing impact of in-container RCE.
|
Guided Remediation
Specify an unprivileged UID:GID (e.g. user: "1000:1000") or ensure the image enforces a non-root USER.
|
DKR011Pro |
MEDIUM |
Missing memory limit (mem_limit / deploy.resources.limits.memory)
Service defines no memory ceiling, allowing a memory leak or runaway workflow to trigger host-wide OOM kills.
|
Guided Remediation
Set mem_limit (e.g. 1g) or deploy.resources.limits.memory.
|
DKR012Pro |
CRITICAL |
Sensitive host path bind-mounted into container
Service bind-mounts a sensitive host path (/, /etc, /root, /proc, /sys, ~/.ssh, ~/.aws) into the container.
|
Guided Remediation
Use named Docker volumes or narrowly scoped application data directories.
|
DKR013Pro |
MEDIUM |
Host PID or IPC namespace shared (pid: host / ipc: host)
Sharing the host PID or IPC namespace lets container processes inspect or signal processes running on the host.
|
Guided Remediation
Remove pid: host and ipc: host from the service definition.
|
DKR014Pro |
MEDIUM |
Missing no-new-privileges security option
Service does not set security_opt: ['no-new-privileges:true'], allowing processes to gain privileges via setuid/setgid binaries.
|
Guided Remediation
Add security_opt: ["no-new-privileges:true"] to harden the container.
|
DKR015Pro |
HIGH |
n8n container missing N8N_ENCRYPTION_KEY
An n8n service does not configure N8N_ENCRYPTION_KEY, risking random key regeneration and permanent loss of encrypted credentials on redeploy.
|
Guided Remediation
Set N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY:?required} using a persistent 32+ char key stored securely.
|
DKR016Pro |
MEDIUM |
Insecure TLS or cookie override in Docker environment
Service environment sets N8N_SECURE_COOKIE=false or NODE_TLS_REJECT_UNAUTHORIZED=0, weakening transport/session security.
|
1-Click IDE Quick Fix
Set N8N_SECURE_COOKIE=true behind HTTPS and remove NODE_TLS_REJECT_UNAUTHORIZED=0.
|
DKR017Pro |
LOW |
Writable root filesystem (read_only not enabled)
Service does not enable read_only: true, allowing compromised processes to drop binaries or tamper with runtime files.
|
Guided Remediation
Enable read_only: true with explicit tmpfs or named volumes for writable paths.
|
DKR018Pro |
LOW |
Missing container log rotation (logging.options.max-size)
Service does not configure logging rotation (max-size / max-file), risking host disk exhaustion on noisy production containers.
|
Guided Remediation
Configure logging driver json-file with options max-size: '10m' and max-file: '3'.
|
Frequently Asked Questions
Does this Docker Compose security checker send my compose file to a backend?
No. StackGuard parses your YAML AST directly inside your browser via scanner-bundle.js. Zero bytes of your docker-compose.yml, environment variables, or service topology are sent over the network.
Why does StackGuard flag ports like 5432:5432 or 6379:6379?
Docker publishes host ports on 0.0.0.0 by default, bypassing common UFW firewall rules on Linux VPS hosts. Rule DKR001 catches exposed database, cache, and admin ports and offers a 1-click IDE Quick Fix to bind strictly to 127.0.0.1.
Does it check self-hosted AI & n8n Docker Compose deployments?
Yes. Beyond container hardening (privileged: true, docker.sock, cap_add, root user, mem_limit, healthcheck, restart policy, no-new-privileges, read_only, log rotation), StackGuard specifically validates n8n production requirements such as N8N_ENCRYPTION_KEY (DKR015) and N8N_SECURE_COOKIE / TLS overrides (DKR016).
How do I run all 18 Docker rules locally in VS Code or CI?
Download the free stackguard-0.2.0.vsix extension for instant Problems-panel diagnostics and 1-click Quick Fixes, or upgrade once to StackGuard Pro ($29 Solo / $49 Team via Polar.sh) to unlock all 72 rules across MCP, n8n, Docker, and Caddy/Traefik with SARIF 2.1.0 and compliance reports.