New to Claude Skills? Learn how to install them →

mukul975 on GitHub

Implementing Container Image Minimal Base

Free

Harden your container images with distroless base images.

Get this skill

Free · Opens the source repo

What Implementing Container Image Minimal Base does

The Implementing Container Image Minimal Base with Distroless skill is designed for developers and security professionals looking to enhance the security of their containerized applications. By utilizing Google distroless base images, this skill allows users to build application images that contain only the necessary runtime dependencies, significantly reducing the attack surface associated with traditional container images. Distroless images do not include package managers, shells, or other utilities, which means they are less prone to exploitation and vulnerabilities.

This skill leverages multi-stage Docker builds to create minimal images tailored for various programming languages, including Go, Java, Python, and Node.js. It provides example Dockerfiles that demonstrate how to structure builds effectively, ensuring that only the essential components are included in the final image. By following the provided patterns, developers can ensure that their applications are not only lightweight but also secure against common attack vectors.

In addition to building images, this skill also addresses the need for compliance with security standards. It is particularly useful for organizations conducting security assessments or hardening their container security architecture. The skill's focus on reducing known vulnerabilities makes it a valuable tool for maintaining a secure development lifecycle.

Furthermore, the skill includes techniques for debugging distroless containers, recognizing that the absence of a shell can complicate troubleshooting. It guides users on how to use debug variants and ephemeral debug containers to inspect and diagnose issues without compromising the security benefits of using distroless images.

When to use it

Use this skill when building or deploying container images that require a minimal attack surface for enhanced security.

When not to use it

This skill may not be suitable for applications that require extensive OS utilities or package management within the container.

What you can build with it

Deploying Secure Applications

Use this skill to build and deploy applications with minimal attack surfaces, ensuring compliance with security standards.

Conducting Security Assessments

Utilize this skill when performing security assessments that require the implementation of hardened container images.

Improving Security Architecture

Incorporate this skill into your security architecture to enhance the overall security posture of your containerized applications.

How to install Implementing Container Image Minimal Base

View source

1. Install with the skills CLI

npx skills add mukul975/anthropic-cybersecurity-skills/implementing-container-image-minimal-base-with-distroless --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mukul975

Implementing Container Image Minimal Base with Distroless

Overview

Google distroless images contain only your application and its runtime dependencies, without package managers, shells, or other programs found in standard Linux distributions. By eliminating unnecessary OS components, distroless images achieve up to 95% reduction in attack surface compared to traditional base images like ubuntu or debian. Major projects including Kubernetes itself, Knative, and Tekton use distroless images in production. As of 2025, Docker also offers Hardened Images (DHI) as an open-source alternative for minimal container bases.

When to Use

  • When deploying or configuring implementing container image minimal base with distroless capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • Docker 20.10+ or compatible container build tool (Buildah, Kaniko)
  • Multi-stage Dockerfile knowledge
  • Application compiled as a static binary or with runtime bundled
  • Container registry for image storage

Available Distroless Images

ImageUse CaseSize
gcr.io/distroless/static-debian12Statically compiled binaries (Go, Rust)~2MB
gcr.io/distroless/base-debian12Dynamically linked binaries needing glibc~20MB
gcr.io/distroless/cc-debian12C/C++ applications needing libstdc++~25MB
gcr.io/distroless/java21-debian12Java 21 applications~220MB
gcr.io/distroless/python3-debian12Python 3 applications~50MB
gcr.io/distroless/nodejs22-debian12Node.js 22 applications~130MB

Multi-Stage Build Patterns

Go Application

# Build stage
FROM golang:1.22-bookworm AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /server ./cmd/server

# Runtime stage - static distroless
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /server /server
USER nonroot:nonroot
ENTRYPOINT ["/server"]

Java Application

# Build stage
FROM maven:3.9-eclipse-temurin-21 AS builder
WORKDIR /app
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src ./src
RUN mvn package -DskipTests

# Runtime stage - Java distroless
FROM gcr.io/distroless/java21-debian12:nonroot
COPY --from=builder /app/target/app.jar /app.jar
USER nonroot:nonroot
ENTRYPOINT ["java", "-jar", "/app.jar"]

Python Application

# Build stage
FROM python:3.12-bookworm AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --target=/deps -r requirements.txt
COPY . .

# Runtime stage - Python distroless
FROM gcr.io/distroless/python3-debian12:nonroot
WORKDIR /app
COPY --from=builder /deps /deps
COPY --from=builder /app /app
ENV PYTHONPATH=/deps
USER nonroot:nonroot
ENTRYPOINT ["python3", "/app/main.py"]

Node.js Application

# Build stage
FROM node:22-bookworm AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .

# Runtime stage - Node distroless
FROM gcr.io/distroless/nodejs22-debian12:nonroot
WORKDIR /app
COPY --from=builder /app .
USER nonroot:nonroot
CMD ["server.js"]

Security Benefits

Attack Surface Comparison

ComponentUbuntuAlpineDistroless
Shell (bash/sh)YesYesNo
Package manageraptapkNo
coreutilsFullBusyBoxNo
curl/wgetYesYesNo
User managementYesYesNo
Known CVEs (typical)50-200+5-200-5
Image size (base)~77MB~7MB~2-20MB

Security Implications

  • No shell: Attackers cannot exec into containers to run commands
  • No package manager: Cannot install additional tools or malware
  • No coreutils: No cat, ls, find, curl for reconnaissance
  • Minimal CVEs: Fewer packages means fewer vulnerabilities to patch
  • Non-root by default: :nonroot tag runs as UID 65534

Debugging Distroless Containers

Since distroless has no shell, use these techniques for debugging:

Debug Image Variant

# Use debug variant in non-production environments only
FROM gcr.io/distroless/base-debian12:debug
# Includes busybox shell at /busybox/sh
# Exec into debug variant
kubectl exec -it pod-name -- /busybox/sh

Ephemeral Debug Containers (Kubernetes 1.25+)

# Attach a debug container with full tooling
kubectl debug -it pod-name --image=busybox:1.36 --target=app-container

Crane/Dive for Image Inspection

# Inspect image layers without running
crane export gcr.io/distroless/static-debian12 - | tar -tf - | head -50

# Analyze image layers
dive gcr.io/distroless/static-debian12

Image Scanning Results

Typical vulnerability comparison using Trivy:

# Scan Ubuntu-based image
trivy image myapp:ubuntu
# Result: 47 vulnerabilities (3 CRITICAL, 12 HIGH)

# Scan Distroless-based image
trivy image myapp:distroless
# Result: 2 vulnerabilities (0 CRITICAL, 0 HIGH)

References

Frequently asked questions about Implementing Container Image Minimal Base

Similar skills