본문으로 건너뛰기
Skillpedia
이미지 및 아이콘35k · #8019

implementing-container-image-minimal-base-with-distroless

하는 일

이 스킬은 더 안전한 컨테이너 이미지를 만드는 데 도움을 줍니다. ‘distroless’라는 특별한 기반을 사용하는데, 이는 애플리케이션 실행에 필요한 것만 포함하고 위험이 될 수 있는 불필요한 요소는 제거합니다.

사용하는 경우

  • ✓컨테이너의 공격 표면을 줄이고 싶을 때.
  • ✓컨테이너화된 애플리케이션의 보안을 설정할 때.
  • ✓보안 요구 사항이나 평가에 대응해야 하는 경우.

스킬 링크

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-container-image-minimal-base-with-distroless/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-container-image-minimal-base-with-distroless/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Go 애플리케이션을 위해 distroless를 사용해 더 안전한 컨테이너 이미지를 만들려면 어떻게 해야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 두 단계 과정을 사용합니다. 먼저 애플리케이션을 컴파일합니다. 그다음 필요한 실행 환경만 담긴 최소한의 ‘distroless’ 기반 이미지에 복사합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

Image Use Case Size
gcr.io/distroless/static-debian12 Statically compiled binaries (Go, Rust) ~2MB
gcr.io/distroless/base-debian12 Dynamically linked binaries needing glibc ~20MB
gcr.io/distroless/cc-debian12 C/C++ applications needing libstdc++ ~25MB
gcr.io/distroless/java21-debian12 Java 21 applications ~220MB
gcr.io/distroless/python3-debian12 Python 3 applications ~50MB
gcr.io/distroless/nodejs22-debian12 Node.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

Component Ubuntu Alpine Distroless
Shell (bash/sh) Yes Yes No
Package manager apt apk No
coreutils Full BusyBox No
curl/wget Yes Yes No
User management Yes Yes No
Known CVEs (typical) 50-200+ 5-20 0-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

…
자주 묻는 질문

‘distroless’ 이미지란 무엇인가요?

셸이나 패키지 관리자 같은 추가 도구 없이, 애플리케이션과 실행에 필요한 의존성만 담고 있는 컨테이너 이미지입니다.

‘distroless’의 장점은 무엇인가요?

알려진 취약점이 있거나 컨테이너를 공격하는 데 쓰일 수 있는 구성 요소를 제거하여 공격 표면을 크게 줄입니다.

셸이 없는 ‘distroless’ 컨테이너는 어떻게 디버그하나요?

디버그용 이미지 변형을 사용하거나, Kubernetes의 임시 디버그 컨테이너를 사용하거나, Crane과 Dive 같은 도구로 이미지를 검사하는 방법이 있습니다.

상세 정보

작성자의 원본 설명

Reduces container attack surface by building application images on Google distroless base images that ship only the application runtime - no shell, package manager, or OS utilities - using multi-stage build patterns plus debugging and scanning techniques adapted to distroless. Use when hardening container images, cutting attack surface in a container architecture, or answering an assessment findin

repo: mukul975/Anthropic-Cybersecurity-Skills

인기도

GitHub 스타
35k
순위
#8019
라이선스
Apache-2.0
업데이트
2026. 8. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬