agentleFS
backspace-shmackspacebackspace-shmackspace/claude-devkit/skills/container-hardening/SKILL.md

container-hardening

Skill15 starsChanged 3 months agoMITView on GitHub

Harden container images and runtime configuration. Use when building, reviewing, or auditing Containerfiles, Dockerfiles, container compose files, or Kubernetes pod security settings.

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

7 rules. About 0 are common, 5 are distinctive, and 2 are 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.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use a Universal Base Image (UBI) from the official Red Hat Container Registry

    line 13
  2. Very specific:

    Prefer ubi-minimal (ubi8/ubi-minimal or ubi9/ubi-minimal) to reduce attack surface

    line 14
  3. Distinctive:

    Use the most up-to-date image available

    line 15
  4. Distinctive:

    Remove non-essential packages and clean up package manager caches:

    line 26
  5. Very specific:

    Use microdnf on ubi-minimal images.

    line 35
  6. Distinctive:

    Use read-only root filesystems wherever possible:

    line 57
  7. Distinctive:

    Use Hadolint to lint Containerfiles for best-practice violations and inline bash issues:

    line 79

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Container Hardening

Base Image Selection

  • Use a Universal Base Image (UBI) from the official Red Hat Container Registry
  • Prefer ubi-minimal (ubi8/ubi-minimal or ubi9/ubi-minimal) to reduce attack surface
  • Use the most up-to-date image available

Image Tagging Strategy

SourceStrategy
Red Hat CatalogOmit floating tags to get the latest image; exception: Konflux project uses digest-based pinning with automated updates
Non-Red Hat registriesPin the version or digest to ensure you use the intended image and not a tampered one

Minimize Installed Software

Remove non-essential packages and clean up package manager caches:

RUN microdnf upgrade -y && \
    microdnf install -y <required-packages> && \
    microdnf remove -y <unnecessary-packages> && \
    microdnf clean all

Use microdnf on ubi-minimal images; dnf on full UBI images.

Runtime Security

Privilege Restrictions

Set no-new-privileges to prevent privilege escalation during container execution:

securityContext:
  allowPrivilegeEscalation: false

Or in a compose file:

security_opt:
  - no-new-privileges: true

Read-Only Filesystem

Use read-only root filesystems wherever possible:

securityContext:
  readOnlyRootFilesystem: true

Mount writable tmpfs volumes only where the application requires write access (e.g., /tmp, /var/run).

Read-Only Volumes

Mount volumes as read-only unless the container must write to them:

volumeMounts:
  - name: config
    mountPath: /etc/app
    readOnly: true

Containerfile Linting

Use Hadolint to lint Containerfiles for best-practice violations and inline bash issues:

hadolint Containerfile

Hadolint catches common issues (running as root, missing version pins, unnecessary sudo) but should not be trusted without additional verification.

Implementation Checklist

  • Base image is a Red Hat UBI from the official catalog
  • ubi-minimal is used unless a full UBI is justified
  • Non-Red Hat base images are pinned by version or digest
  • Non-essential packages are removed and caches cleaned
  • allowPrivilegeEscalation: false (no-new-privileges) is set
  • readOnlyRootFilesystem: true is set
  • Volumes are mounted read-only unless writes are required
  • A numeric non-root USER is set in the Containerfile
  • Hadolint runs in CI on all Containerfiles
  • Container images are rebuilt regularly to pick up base image updates

References

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.