advancedPerformance Optimization: Layer Caching, Multi-Stage Builds & Alpine

What's the practical difference between choosing Alpine vs distroless for a production image?

Alpine generally produces the smallest raw image size and retains a shell and package manager (busybox-provided), which is convenient for interactive debugging but means more available tooling if an attacker gains code execution. Distroless removes the shell and package manager entirely, slightly increasing size relative to a minimal Alpine image in some cases but meaningfully reducing the post-compromise attack surface, at the cost of needing a separate debug-variant image (most distroless families publish a debug tag) for any interactive troubleshooting.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why does instruction ordering matter even when a multi-stage build is already in use?← Back to all Docker questions