- Why does layer order matter in a Dockerfile?
- Docker caches each layer. If a layer changes, all subsequent layers must be rebuilt. Placing frequently-changing instructions (COPY app code) after infrequently-changing ones (npm install) maximizes cache hits and minimizes rebuild time.
- What is a distroless image?
- A container image that contains only the application and its runtime dependencies — no shell, package manager, or OS utilities. Distroless images (Google's gcr.io/distroless) have a much smaller attack surface because there are no tools for an attacker to leverage if the container is compromised.
- How small can a production container image be?
- A Go HTTP server can compile to a static binary and run in a FROM scratch image (0MB base) — total image size can be under 10MB. Node.js has a minimum runtime overhead of ~70MB. Python ~80MB. Alpine-based images for these runtimes: ~150MB for Node, ~120MB for Python.