AI-powered Docker security scanner that explains vulnerabilities in plain English
What is DockSec?
DockSec is an OWASP Lab Project that bridges the gap between complex security scan results and actionable developer fixes. It integrates industry-standard scanners (Trivy, Hadolint, Docker Scout) with AI to provide context-aware security analysis.
Instead of overwhelming you with a list of 200+ CVEs, DockSec:
- Prioritizes what actually affects your specific container setup.
- Explains vulnerabilities in plain English, not just security jargon.
- Suggests specific fixes for your Dockerfile.
- Generates professional, interactive security reports for your team.
Everything scans locally. When enabled, DockSec sends only the data required for EPSS lookups or AI analysis, with secrets redacted before AI requests. With a local model, scan-only mode, or offline mode, no scan data leaves your machine. See Data flow and privacy.
How It Works
DockSec workflow: from scanning to actionable insights
DockSec follows a five-stage pipeline:
- Scan: Runs Trivy (image vulnerabilities and Dockerfile misconfigurations),
Hadolint, and Docker Scout locally on your environment.
- Prioritize: Ranks every CVE finding by severity combined with its
EPSS exploitation likelihood, so the list is
ordered by what to fix first rather than by what was found first.
- Correlate: Detects exploit chains where separate
findings combine into one attack path - a credentialed database that an
internet-facing service can reach is a chain, not two unrelated findings.
With an API key, an AI pass reasons over the full scan output to rank, explain,
and extend this.
- Recommend: Produces copy-and-run fix commands and concrete Dockerfile or
compose changes, and states how many findings they resolve.
- Report: Exports actionable results as HTML, PDF, JSON, CSV, Markdown, SARIF, and CycloneDX SBOM.
Getting Started
1. Prerequisites
DockSec orchestrates local scanners, so it needs:
| Requirement |
Needed for |
Install |
| Python 3.12+ |
DockSec itself |
python.org |
| Trivy |
All scans (required) |
brew install trivy or Trivy docs |
| Hadolint |
Dockerfile linting |
brew install hadolint or Hadolint docs |
| Docker |
Image scans (-i) |
Docker docs |
Or let DockSec install Trivy and Hadolint for you:
python -m docksec.setup_external_tools
2. Install DockSec
# Full install with AI analysis support (recommended)
pip install "docksec[ai]"
# Or the slim, scan-only core (no LLM dependencies, no API key needed)
pip install docksec
3. Run your first scan
No API key needed for local scanning:
docksec Dockerfile --scan-only
Every scan ends with a result summary: a severity table, a 0-100 security score with a
rating, a "Quick take" action block, the generated reports (saved to
~/.docksec/results/ by default), and a suggested next command.
4. Enable AI analysis
AI analysis explains findings and suggests fixes. Pick a provider, set its API key, and run:
# OpenAI (default provider)
export OPENAI_API_KEY="sk-..."
docksec Dockerfile
# Anthropic Claude
export ANTHROPIC_API_KEY="sk-ant-..."
docksec Dockerfile --ai-only --provider anthropic --model claude-sonnet-5
# Google Gemini
export GOOGLE_API_KEY="..."
docksec Dockerfile --ai-only --provider google
# Ollama (fully local, no API key, data never leaves your machine)
docksec Dockerfile --ai-only --provider ollama --model llama3.1
Each provider has a sensible default model (OpenAI: gpt-4o, Anthropic:
claude-haiku-4-5, Google: gemini-1.5-pro, Ollama: llama3.1), so --model is
optional. To avoid repeating flags, set environment variables (or put them in a .env
file in the directory you run from - DockSec loads it automatically):
export LLM_PROVIDER=anthropic
export LLM_MODEL=claude-sonnet-5
docksec Dockerfile
Before any content is sent to an AI provider, secret-looking values (passwords, tokens,
API keys, private key blocks) are masked automatically. See
Data flow and privacy.
5. Or run the container image (nothing to install)
The published image bundles pinned versions of Trivy and Hadolint, so there is
nothing to install and nothing to configure:
docker run --rm -v "$PWD:/github/workspace" \
-e INPUT_DOCKERFILE=Dockerfile \
-e INPUT_SCAN_ONLY=true \
ghcr.io/owasp/docksec:latest
Also published to Docker Hub as owasp/docksec:
docker run --rm -v "$PWD:/github/workspace" \
-e INPUT_DOCKERFILE=Dockerfile \
-e INPUT_SCAN_ONLY=true \
owasp/docksec:latest
Published multi-arch (amd64 and arm64) on every release, to both registries
from the same build. Pin to a specific version (ghcr.io/owasp/docksec:2026.9.21,
owasp/docksec:2026.9.21) or a minor series (ghcr.io/owasp/docksec:2026.9)
rather than latest in CI. Every GHCR image carries a build provenance
attestation:
gh attestation verify oci://ghcr.io/owasp/docksec:latest --repo OWASP/DockSec
The image reads the same INPUT_* variables as the GitHub Action, so any Action
input works here: INPUT_IMAGE, INPUT_COMPOSE, INPUT_SEVERITY,
INPUT_FAIL_ON, INPUT_FORMAT, INPUT_SARIF, INPUT_OUTPUT_DIR. Write reports
somewhere on the mount to keep them after the container exits:
docker run --rm -v "$PWD:/github/workspace" \
-e INPUT_COMPOSE=docker-compose.yml \
-e INPUT_SCAN_ONLY=true \
-e INPUT_FORMAT=json,html \
-e INPUT_OUTPUT_DIR=/github/workspace/docksec-reports \
ghcr.io/owasp/docksec:latest
6. Or use the GitHub Action
- name: Run DockSec AI Scanner
uses: OWASP/DockSec@v2026.9.21
with:
dockerfile: 'Dockerfile'
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
Common Commands
# Scan Dockerfile + Docker image (AI + scanners)
docksec Dockerfile -i myapp:latest
# Scan a Docker Compose file and all its services
docksec --compose docker-compose.yml
# Scan only a Docker image
docksec --image-only -i myapp:latest
# Fast local scan, no AI, no API key
docksec Dockerfile --scan-only
# Choose which severity levels the image scan reports (default: CRITICAL,HIGH)
docksec -i myapp:latest --image-only --severity CRITICAL,HIGH,MEDIUM
# Fail the build (exit 1) if any finding is HIGH or above
docksec -i myapp:latest --image-only --fail-on high
# Write only the report formats you want, to a directory of your choice
docksec Dockerfile --scan-only --format json,html --output-dir ./reports
# Write a Markdown report for posting directly into a pull request comment
docksec Dockerfile --scan-only --format markdown
# Print results as JSON to stdout for scripts and CI pipelines
docksec -i myapp:latest --image-only --json
# Write a SARIF report for GitHub Code Scanning
docksec Dockerfile --scan-only --sarif
# Write a CycloneDX SBOM of an image for supply-chain tooling
docksec --image-only -i myapp:latest --sbom
# Fully offline scan: local Trivy DB, no network, no AI
docksec --image-only -i myapp:latest --offline
# Save today's findings as a baseline, then only gate on new findings later
docksec -i myapp:latest --image-only --baseline .docksec-baseline.json --update-baseline
docksec -i myapp:latest --image-only --baseline .docksec-baseline.json --fail-on high
# Suppress triaged findings with an auditable ignore file
docksec -i myapp:latest --image-only --ignore-file .docksec-ignore.yml
# Force a fresh scan, bypassing the results cache
docksec -i myapp:latest --image-only --no-cache
# Install AI-assistant skill files (Claude Code, Cursor, Copilot, and more)
docksec install-skill
# Output control
docksec Dockerfile --scan-only --quiet # warnings, errors, summary only
docksec Dockerfile --scan-only --verbose # INFO-level diagnostics on stderr
docksec Dockerfile --scan-only --verbose --log-file logs/docksec.log
docksec Dockerfile --scan-only --compact-output # shorter per-finding output
docksec Dockerfile --no-color # also honors NO_COLOR
# Apply the mechanical Dockerfile fixes (keeps a .bak, re-scans, shows the delta)
docksec Dockerfile --scan-only --fix --dry-run # print the diff, change nothing
docksec Dockerfile --scan-only --fix
# Rank findings by severity alone, with no EPSS lookup and no network call
docksec Dockerfile --scan-only --no-epss
# Treat a scan that could not complete as a failure, not a pass
docksec Dockerfile --scan-only --fail-on high --incomplete-policy fail
Configuration file
Commit a .docksec.yml at the root of your repository and the whole team - and
every CI job - scans under the same policy, instead of each developer passing
their own flags.
# yaml-language-server: $schema=https://owasp.org/DockSec/docksec-config-schema.json
severity: CRITICAL,HIGH
fail_on: HIGH
formats: [json, html]
output_dir: ./security-reports
rules:
disabled:
- compose-missing-healthcheck
Every setting is optional; anything you leave out falls back to the environment
variable and then to the built-in default. A full annotated example is in
examples/.docksec.yml.
Precedence
Highest priority first:
CLI flag > environment variable > .docksec.yml > built-in default
So a committed severity: LOW is still overridden by --severity CRITICAL on
the command line, and by DOCKSEC_DEFAULT_SEVERITY in the environment.
Discovery
DockSec looks for .docksec.yml (or .docksec.yaml) in the working directory
and then walks up to the repository root, so a service in a monorepo
subdirectory inherits the policy committed at the top level. The search stops at
the directory containing .git, so it never picks up a file from outside the
repository.
--config FILE uses a specific file instead of searching.
--no-config ignores any config file, for reproducible CI runs.
The config file in force is shown in the scan banner, so it is always clear
which policy was applied.
Settings
| Setting |
Equivalent flag |
Notes |
severity |
--severity |
Severity levels for the image scan |
fail_on |
--fail-on |
CI gate threshold |
formats |
--format |
List form: [json, html] |
output_dir |
--output-dir |
Report destination |
provider |
--provider |
openai, anthropic, google, ollama |
model |
--model |
Model name for the provider |
offline |
--offline |
No network; skips AI and Docker Scout |
skip_ai_scoring |
--skip-ai-scoring |
Deprecated and ignored; scoring is always deterministic |
no_redact |
--no-redact |
Do not mask secrets before the AI call |
no_cache |
--no-cache |
Bypass the scan cache |
ignore_file |
--ignore-file |
Waiver file path |
baseline |
--baseline |
Baseline file path |
rules.disabled |
- |
Rule IDs to switch off entirely |
An invalid config file - an unknown key, a bad severity - is a hard error that
exits 2 rather than a warning, so a broken policy file can never cause a scan
to run under rules the team did not commit.
Editor autocomplete
The # yaml-language-server: comment on the first line gives completion and
inline validation in VS Code and JetBrains editors. The schema is published at
docs/docksec-config-schema.json and can be
regenerated with docksec --print-config-schema.
Disabling rules
rules.disabled switches a check off entirely, everywhere - it is removed
before scoring, reports, --json, and the --fail-on gate. Use it for checks
that do not apply to your environment. For individual findings your team has
triaged and accepted, prefer the waiver file,
whose entries carry a reason and an expiry date and so stay auditable.
CI/CD Integration
Exit codes
DockSec uses CI-friendly exit codes so builds and shells can react to results: