Harden Docker/container images and runtime deployments with secure base images, non-root users, CVE scanning, SBOM/signing, seccomp/AppArmor, and Kubernetes pod security controls. Use for Dockerfile security reviews, container CVEs, image scanning, distroless images, or production hardening.
A production-focused guide for building, scanning, and running containers securely — from Dockerfile authoring through runtime enforcement and supply chain integrity.
Detailed Guide
Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
When to Use This Skill
User mentions Docker security, container hardening, or Dockerfile security review
User asks about distroless images, non-root containers, or read-only filesystems
User wants to scan images for CVEs with Trivy, Grype, or Snyk
User mentions seccomp, AppArmor, Linux capabilities, or runtime security
User asks "is my Dockerfile secure?" or "how do I reduce my image attack surface?"
User wants to sign/verify images with Cosign or generate SBOMs
User asks about Kubernetes pod security, NetworkPolicy, or RBAC hardening
User says "fix container CVEs" or "harden my container for production"
When NOT to Use This Skill
The user is primarily asking about GitHub Actions CI/CD → recommend github-actions-advanced
The user needs general Docker usage help (not security) → recommend docker-expert
The user is working with Kubernetes orchestration beyond security → recommend kubernetes-architect
The user needs application-level security (SQL injection, XSS) → recommend api-security-best-practices
Security Checklist
Dockerfile
Minimal base image (distroless, slim, or alpine — not full debian/ubuntu)
Multi-stage build — no build tools, devDependencies, or compilers in runtime image
Non-root USER declared before CMD/ENTRYPOINT
Base image pinned to @sha256:... digest (not just tag)
No secrets in ENV, ARG, or RUN commands
HEALTHCHECK defined
OCI labels present (org.opencontainers.image.*)
.dockerignore excludes .git, .env, secrets, tests
ENTRYPOINT uses exec form, not shell form
Image Scanning
Trivy or Grype scan in CI (fails on HIGH/CRITICAL)
Hadolint passes with no warnings
Secret scan run on image (trivy --scanners secret)
SBOM generated and stored
.trivyignore has justified entries for accepted CVEs
Runtime
--read-only filesystem
--cap-drop ALL (add back only what's documented as required)
--security-opt no-new-privileges:true
--security-opt seccomp=<profile> applied
Resource limits set (--memory, --cpus, --pids-limit)
Image signed with Cosign; verified before deploy
Kubernetes
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
runAsNonRoot: true with explicit UID
capabilities.drop: ["ALL"]
Resource requests and limits defined
automountServiceAccountToken: false
Namespace PSA enforced at restricted level
NetworkPolicy default-deny applied
RBAC uses specific resource names and minimal verbs
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific penetration testing or a formal security audit.
Seccomp profiles and AppArmor are Linux-only; macOS/Windows Docker Desktop uses different mechanisms.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: container-security-hardening3description: >4 Harden Docker/container images and runtime deployments with secure base images,5 non-root users, CVE scanning, SBOM/signing, seccomp/AppArmor, and Kubernetes6 pod security controls. Use for Dockerfile security reviews, container CVEs,7 image scanning, distroless images, or production hardening.8category: security9risk: safe10source: community11date_added: "2026-05-30"12metadata:13 source: https://skillmd.com/skills/francostino/container-security-hardening14---1516# Container Security Hardening Skill1718A production-focused guide for building, scanning, and running containers securely — from Dockerfile authoring through runtime enforcement and supply chain integrity.1920---2122## Detailed Guide2324Read [the detailed guide](references/detailed-guide.md) before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.2526## When to Use This Skill2728- User mentions Docker security, container hardening, or Dockerfile security review29- User asks about distroless images, non-root containers, or read-only filesystems30- User wants to scan images for CVEs with Trivy, Grype, or Snyk31- User mentions seccomp, AppArmor, Linux capabilities, or runtime security32- User asks "is my Dockerfile secure?" or "how do I reduce my image attack surface?"33- User wants to sign/verify images with Cosign or generate SBOMs34- User asks about Kubernetes pod security, NetworkPolicy, or RBAC hardening35- User says "fix container CVEs" or "harden my container for production"3637## When NOT to Use This Skill3839- The user is primarily asking about GitHub Actions CI/CD → recommend `github-actions-advanced`40- The user needs general Docker usage help (not security) → recommend `docker-expert`41- The user is working with Kubernetes orchestration beyond security → recommend `kubernetes-architect`42- The user needs application-level security (SQL injection, XSS) → recommend `api-security-best-practices`4344---4546## Security Checklist4748### Dockerfile49- [ ] Minimal base image (distroless, slim, or alpine — not full debian/ubuntu)50- [ ] Multi-stage build — no build tools, devDependencies, or compilers in runtime image51- [ ] Non-root `USER` declared before `CMD`/`ENTRYPOINT`52- [ ] Base image pinned to `@sha256:...` digest (not just tag)53- [ ] No secrets in `ENV`, `ARG`, or `RUN` commands54- [ ] `HEALTHCHECK` defined55- [ ] OCI labels present (`org.opencontainers.image.*`)56- [ ] `.dockerignore` excludes `.git`, `.env`, secrets, tests57- [ ] `ENTRYPOINT` uses exec form, not shell form5859### Image Scanning60- [ ] Trivy or Grype scan in CI (fails on HIGH/CRITICAL)61- [ ] Hadolint passes with no warnings62- [ ] Secret scan run on image (`trivy --scanners secret`)63- [ ] SBOM generated and stored64- [ ] `.trivyignore` has justified entries for accepted CVEs6566### Runtime67- [ ] `--read-only` filesystem68- [ ] `--cap-drop ALL` (add back only what's documented as required)69- [ ] `--security-opt no-new-privileges:true`70- [ ] `--security-opt seccomp=<profile>` applied71- [ ] Resource limits set (`--memory`, `--cpus`, `--pids-limit`)72- [ ] Image signed with Cosign; verified before deploy7374### Kubernetes75- [ ] `readOnlyRootFilesystem: true`76- [ ] `allowPrivilegeEscalation: false`77- [ ] `runAsNonRoot: true` with explicit UID78- [ ] `capabilities.drop: ["ALL"]`79- [ ] Resource `requests` and `limits` defined80- [ ] `automountServiceAccountToken: false`81- [ ] Namespace PSA enforced at `restricted` level82- [ ] `NetworkPolicy` default-deny applied83- [ ] RBAC uses specific resource names and minimal verbs8485---8687## Limitations8889- Use this skill only when the task clearly matches the scope described above.90- Do not treat the output as a substitute for environment-specific penetration testing or a formal security audit.91- Seccomp profiles and AppArmor are Linux-only; macOS/Windows Docker Desktop uses different mechanisms.92- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Run npx get-skill add francostino/container-security-hardening in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Harden Docker/container images and runtime deployments with secure base images, non-root users, CVE scanning, SBOM/signing, seccomp/AppArmor, and Kubernetes pod security controls. Use for Dockerfile security reviews, container CVEs, image scanning, distroless images, or production hardening. It is listed under DevOps & Infra on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. Capability flags: reads secrets. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
FrancoStino (@francostino) published this skill. Their other Agent Skills are listed on their SkillMD profile.