agentleFS
XData-siXData-si/xdata-agenthub/skills/docker-hardening/SKILL.md

docker-hardening

Skill1 starsChanged 33 days agoMITView on GitHub

Harden Dockerfiles, images and container runtime settings — minimal base images, non-root users, pinned digests, capabilities and secrets handling. Use when writing or reviewing a Dockerfile or Compose file, or before deploying containers.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check runtime user with docker image inspect IMAGE --format '{{json .Config.User}}'.

    line 14
  2. Distinctive:

    Run vulnerability and SBOM tooling appropriate to the environment.

    line 19
  3. Distinctive:

    Test startup, health, graceful shutdown, upgrade and rollback in a disposable environment.

    line 20
  4. Distinctive:

    No privileged mode, host PID/network or Docker socket mounts without documented exception.

    line 40
  5. Distinctive:

    Only required ports and mounts are exposed.

    line 41
  6. Distinctive:

    Test hardening changes in a disposable environment first.

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Docker Hardening

Goal

Reduce container attack surface without breaking application behavior.

Review checklist

  1. Identify base image and pin a specific release or digest; document update cadence.
  2. Check runtime user with docker image inspect IMAGE --format '{{json .Config.User}}'. Prefer non-root where supported.
  3. Inspect mounts, published ports, environment variables, network connectivity and writable directories.
  4. Review Linux capabilities; drop unnecessary capabilities, disallow privilege escalation and use a read-only root filesystem when feasible.
  5. Configure memory/CPU limits, health checks, restart policy and log rotation.
  6. Move secrets out of Dockerfiles and image layers; use approved secret delivery.
  7. Run vulnerability and SBOM tooling appropriate to the environment; record versions and findings.
  8. Test startup, health, graceful shutdown, upgrade and rollback in a disposable environment.

Example Compose baseline

services:
  app:
    image: example/app:1.2.3 # replace with verified digest for production
    user: "10001:10001"
    read_only: true
    cap_drop: [ALL]
    security_opt: ["no-new-privileges:true"]
    tmpfs: ["/tmp:rw,noexec,nosuid,size=64m"]
    pids_limit: 256
    mem_limit: 512m
    restart: unless-stopped

This is an illustrative baseline; adjust writable paths, UID and probes to the actual image.

Acceptance checks

  • Application works under the intended non-root identity.
  • No privileged mode, host PID/network or Docker socket mounts without documented exception.
  • Only required ports and mounts are exposed.
  • Rollback and data persistence are tested.

Output

Risk-ranked findings, evidence, recommended changes and test results.

Safety

Test hardening changes in a disposable environment first; dropping capabilities, read-only file systems or user changes can stop services. Never bake secrets into images, and do not pull or run unverified images on production hosts. Production restarts and redeploys require approval.

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.