Interview Prep/Docker/Image Security & Hardening

How do you remove the package manager and shell from a final image built on Debian?

IntermediateProductionImage Security & Hardening
Answer

Prefer distroless. If you must keep Debian slim, remove tooling in a final layer sequence carefully:

RUN rm -f /bin/sh /bin/bash /usr/bin/apt* /usr/bin/dpkg* 2>/dev/null || true

This is brittle (entrypoints often need sh), so we usually copy the app into a distroless runtime stage instead.

All Docker questions Roadmap: Docker & containers

More on Image Security & Hardening