agentleFS
Vimalk0703Vimalk0703/shipworthy/skills/security/container-security/SKILL.md

container-security

Skill6 starsChanged 8 months agoMITView on GitHub

Dockerfile best practices, secure base images, no secrets in build context, multi-stage builds, non-root execution, and image scanning guidance.

  • Reads credentials

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use iac-security and api-security.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • UnitOneAISkill

    iac-security

    Performs a security review of Infrastructure as Code templates against the OWASP IaC Security Cheat Sheet, SLSA v1.0, and CIS Benchmarks. Auto-invoked when reviewing Terraform, CloudFormation, or Pulumi configurations. Detects hardcoded secrets, public exposure patterns, encryption gaps, overly permissive IAM, and misconfigurations equivalent to Checkov, tfsec, and KICS rules. Produces a structured findings report with remediation guidance.

    Also in 4 projects that use this

  • jefflesterSkill

    api-security

    API security best practices and common vulnerability prevention. Enforces security checks for authentication, input validation, SQL injection, XSS, and OWASP Top 10 vulnerabilities. Use when building or modifying APIs.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep build tools out of the final image:

    line 40
  2. Very specific:

    Always run as a non-root user.

    line 60
  3. Very specific:

    Every project with a Dockerfile must have a .dockerignore:

    line 69
  4. Distinctive:

    Policy: No CRITICAL vulnerabilities in production images.

    line 85

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Container Security

Base Image Rules

  1. Use official or verified images only -- node:22-slim, python:3.12-slim, alpine:3.20.
  2. Pin by digest, not just tag -- tags are mutable.
  3. Prefer -slim or -alpine variants -- smaller attack surface.
  4. Never use latest -- builds must be reproducible.
# BAD
FROM node:latest

# GOOD -- pinned tag + slim variant
FROM node:22.12-slim

No Secrets in the Dockerfile

Secrets in the build context end up in image layers. Layers are permanent and extractable.

# BAD -- secret baked into the image
ENV DATABASE_URL=postgres://user:password@host/db
COPY .env /app/.env

# GOOD -- inject at runtime via docker run -e or --env-file
# For build-time secrets, use BuildKit secret mounts:
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci

Multi-Stage Builds

Keep build tools out of the final image:

FROM node:22.12-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22.12-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER node
CMD ["node", "dist/server.js"]

Non-Root User

Always run as a non-root user. Most official images ship one (e.g., node).

RUN addgroup --system app && adduser --system --ingroup app app
USER app

.dockerignore Is Required

Every project with a Dockerfile must have a .dockerignore:

.git
.env*
node_modules
*.md
.github
tests
coverage

Image Scanning

Scan images in CI before pushing to a registry. Tools: Trivy (free, fast), Snyk Container, Docker Scout.

Policy: No CRITICAL vulnerabilities in production images. HIGH must be triaged within 7 days.

- name: Scan image
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: myapp:${{ github.sha }}
    severity: CRITICAL,HIGH
    exit-code: 1

Dockerfile Review Checklist

  • Base image is official/verified, pinned to a specific version
  • No ENV or COPY of secrets -- runtime injection only
  • Multi-stage build separates build tools from production image
  • Final stage runs as non-root user
  • .dockerignore exists and excludes .env*, .git, node_modules
  • Image is scanned in CI with a fail-on-critical policy

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.