Container Security
Use When
- The user needs to scan container images for vulnerabilities before release/deploy.
- The user asks to harden Dockerfiles or runtime container settings.
- The user needs SBOM generation, image signing, or signature verification.
- The user wants CI/CD security gates for container builds.
Primary Actions
- Run vulnerability scans with Trivy or Grype.
- Triage findings and decide fix vs documented suppression.
- Harden image build/runtime configuration (non-root, minimal base, reduced privileges).
- Generate SBOMs with syft and sign images with cosign.
- Add CI gates and post-fix re-scan checks.
End-to-End Workflow With Validation Gates
- Scan image (
trivy imageorgrype). - Triage by severity and fix availability.
- Remediate or suppress with documented rationale.
- Re-scan and confirm policy threshold (for example no CRITICAL/HIGH).
- Generate SBOM and attach/store artifact.
- Sign image with cosign.
- Verify signature and publish.
If any gate fails, return to step 2 before shipping.
Quick Commands
# Scan and fail on high/critical
trivy image --severity HIGH,CRITICAL --exit-code 1 myapp:latest
grype myapp:latest --fail-on high
# SBOM
syft myapp:latest -o spdx-json > sbom.spdx.json
# Sign + verify
cosign sign myregistry/myapp:latest
cosign verify myregistry/myapp:latest
Keep SKILL.md Lean; Use Deep References
- Scanning flags, output formats, CI patterns:
- Hardening details and Dockerfile/runtime patterns:
- SBOM/signing/provenance deep dive:
references/supply-chain-security.md
- Validation gates, suppression policy, and failure recovery:
references/security-operations.md