Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bagelhole avatar

Container Hardening

  • 118 installs
  • 44 repo stars
  • Updated May 22, 2026
  • bagelhole/devops-security-agent-skills

Container Hardening is a Claude skill that secures Docker images and container runtime configurations using non-root users, read-only filesystems, and security contexts.

About

Container Hardening is a skill for securing Docker images and container runtime configurations. It shows how to run containers as a non-root user, enforce a read-only root filesystem, drop Linux capabilities, and set Kubernetes security contexts. A developer uses it when building secure container images or hardening deployments against container escape and privilege escalation.

  • Non-root user, read-only filesystem, and dropped capabilities for Docker images
  • Kubernetes securityContext hardening (runAsNonRoot, allowPrivilegeEscalation false)
  • Distroless base images plus Trivy image scanning for HIGH/CRITICAL CVEs

Container Hardening by the numbers

  • 118 all-time installs (skills.sh)
  • Ranked #963 of 2,203 Security skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

container-hardening capabilities & compatibility

Capabilities
container scanning · kubernetes hardening
Works with
docker · kubernetes
Use cases
devops · security audit
From the docs

What container-hardening says it does

- Enable read-only filesystem - Drop all capabilities
SKILL.md
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill container-hardening

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs118
repo stars44
Last updatedMay 22, 2026
Repositorybagelhole/devops-security-agent-skills

What it does

Harden a Docker image and its Kubernetes deployment so containers run non-root with a read-only filesystem and minimal capabilities.

Who is it for?

Developers building secure container images or hardening Docker and Kubernetes deployments against container escape.

Skip if: Scanning images for known CVEs (see container-scanning) or hardening the host OS itself.

When should I use this skill?

Building secure container images, hardening container deployments, or meeting container security requirements.

What you get

A Dockerfile and Kubernetes manifest that run non-root with a read-only filesystem and dropped capabilities.

  • Hardened Dockerfile
  • Kubernetes pod securityContext
  • Trivy scan command

By the numbers

  • 7-item hardening best-practices checklist

Files

SKILL.mdMarkdownGitHub ↗

Container Hardening

Secure container images and runtime configurations.

When to Use This Skill

Use this skill when:

  • Building secure container images
  • Hardening container deployments
  • Meeting container security requirements
  • Implementing defense in depth

Dockerfile Security

# Use minimal base image
FROM alpine:3.18

# Don't run as root
RUN addgroup -g 1001 -S appgroup && \
    adduser -u 1001 -S appuser -G appgroup

# Copy with specific ownership
COPY --chown=appuser:appgroup . /app

# Remove unnecessary packages
RUN apk del --purge build-dependencies && \
    rm -rf /var/cache/apk/*

# Use non-root user
USER appuser

# Read-only filesystem support
WORKDIR /app

Runtime Security

# Run with security options
docker run -d \
  --read-only \
  --tmpfs /tmp \
  --security-opt=no-new-privileges:true \
  --cap-drop=ALL \
  --cap-add=NET_BIND_SERVICE \
  --user 1001:1001 \
  myapp:latest

Kubernetes Security Context

apiVersion: v1
kind: Pod
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1001
    fsGroup: 1001
  containers:
  - name: app
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      capabilities:
        drop: ["ALL"]

Image Scanning

# Scan with Trivy
trivy image --severity HIGH,CRITICAL myapp:latest

# Use distroless images
FROM gcr.io/distroless/static-debian11

Best Practices

  • Use minimal base images
  • Run as non-root user
  • Enable read-only filesystem
  • Drop all capabilities
  • Scan images regularly
  • Sign and verify images
  • Use secrets management

Related Skills

  • container-scanning - Vulnerability scanning
  • kubernetes-hardening - K8s security

Related skills

FAQ

How do I stop a container from running as root?

Create a dedicated user and group in the Dockerfile, COPY files with --chown to that user, and set USER appuser; in Kubernetes set runAsNonRoot: true and runAsUser.

How do I enforce a read-only filesystem?

Run docker with --read-only and mount --tmpfs /tmp, or set readOnlyRootFilesystem: true in the Kubernetes container securityContext.

Securityappsecaudit

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.