Alpine or Debian slim for a Python app with compiled wheels?
IntermediateScenarioImage design and Dockerfile decisions
Answer
Situation read → Alpine uses musl libc; many PyPI wheels are built for glibc (manylinux).
What I'd do → Choose python:3.12-slim (Debian) for packages like numpy, pandas, grpcio, cryptography. Pick Alpine only if all dependencies have musllinux wheels or you accept compiling from source.
Why → On Alpine, pip often compiles from source, which makes builds slow and images larger after installing a toolchain, and can produce subtle runtime differences (DNS resolver, locale, performance).
Interview tip → "Smaller base is not always smaller final image."
More on Image design and Dockerfile decisions
A teammate's Node.js image is 1.2 GB. How do you approach shrinking it?BeginnerYou need to run `apt-get install` in a Dockerfile. How do you write it so the layer stays small and cache-safe?BeginnerWhen would you pick `COPY` over `ADD`?BeginnerA service must run a startup script and then the app. Should you use `CMD`, `ENTRYPOINT`, or both?BeginnerYour Docker build re-installs all Python dependencies on every code change. Fix it.BeginnerProduct asks for a container that runs both nginx and a Python app. What do you say?Beginner