Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

34%
Docker & Containers (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are Distroless and Alpine base images, and what are their trade-offs (`glibc` vs `musl libc`)?

senior LevelCode ExampleDocker & ContainersSystem Design

In Simple Words:

  • Alpine Linux (alpine):
    • Uses musl libc and BusyBox. Extremely small (~5MB base).
    • Trade-off: musl libc has known performance overhead with certain memory allocators, and compiled native C-extensions (like Python numpy, Node grpc, or Rust FFI bindings) may require compilation from source if pre-built wheels targeting musl are unavailable.
  • Distroless Images (GoogleContainerTools):
    • Contains only your application and runtime dependencies. No package managers (apk, apt), no shells (/bin/sh, /bin/bash), and no standard Unix utilities.
    • Built with standard glibc for maximum binary compatibility.
    • Trade-off: Exceptional security (attackers cannot open a reverse shell or download malware), but local interactive debugging requires crictl or ephemeral debug containers.
dockerfile
# Using Google Distroless for Node.js
FROM gcr.io/distroless/nodejs20-debian12
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER nonroot:nonroot
CMD ["dist/server.js"]