C.W.K.
Stream
Lesson 05 of 06 · published

Base image 선택 — full / slim / alpine / distroless / scratch

~14 min · dockerfile, size, security

Level 0Container 호기심
0 XP0/36 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Base image, 작은 거에서 큰 거로

Image크기용도
scratch0 byteStatic binary (Go, Rust)
distroless~20MB강화된 production, 최소 attack surface
alpine~5-50MBGo, Rust, 단순 Node. Python 은 까다로움 (musl).
*-slim~50-150MB대부분 앱. 옳은 디폴트.
full (e.g. python:3.12)~500MB-1GBDev 환경, 빌드 도구 필요할 때

트레이드오프 진짜야

alpine 은 musl libc 써, glibc 아니야. 많은 Python wheel 이 glibc 전용 — pip 가 alpine 에서 소스 컴파일로 fallback. 빌드 시간 10배 늘 수 있어. Go 나 Rust (static binary) 면 alpine 좋아. Python 앱이면 진짜 알고 하는 게 아닌 한 -slim 써.

distroless image 는 shell 도 package manager 도 없어. docker exec -it ... bash 못 해. production 강화엔 좋아. 즉석 디버깅엔 고통.

scratch 는 진짜 비어있음. dynamic linking 없는 static binary 만 동작. 최대 미니멀, 옳은 도구일 때만.

Code

같은 Python 앱, 네 base·dockerfile
# 1. python:3.12 (full)         -> ~1GB final image
# 2. python:3.12-slim           -> ~150MB
# 3. python:3.12-alpine         -> ~50MB but pip might compile wheels
# 4. gcr.io/distroless/python3  -> ~50MB, no shell

# Recommendation for most Python apps:
FROM python:3.12-slim
# Solid balance of size, compatibility, debuggability.
Go: scratch 가 빛나는 곳·dockerfile
FROM golang:1.23-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app ./cmd/server

FROM scratch
COPY --from=builder /app /app
ENTRYPOINT ["/app"]

# Final image is just the Go binary. Maybe 15MB.
# No shell, no libc, no anything. Maximum minimalism.

External links

Exercise

본인 Python 또는 Go 프로젝트 하나 골라. (a) full base, (b) slim, (c) alpine 으로 빌드. 빌드 시간이랑 최종 크기 기록. Python 이면 alpine 에서 소스 컴파일로 빠진 wheel 확인. production 용 옳은 base 골라서 두 문장으로 정당화.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.