apt-get install --no-install-recommends
I reach for --no-install-recommends in a lot of Dockerfiles now. Debian and Ubuntu packages have hard dependencies plus a set of “recommended” packages, and apt-get install pulls in the recommends by default. That is fine on a desktop, but it is bloat you rarely want in an image.
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
apt install takes the same flag, but stick with apt-get in a Dockerfile. In a script apt prints WARNING: apt does not have a stable CLI interface. Use with caution in scripts., and its man page recommends apt-get for scripts because it keeps backward compatibility.
Ubuntu measured a 60% image size reduction from this flag on their own images.
To make it the default for every install in an image instead of repeating the flag, set it in an apt config:
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/99norecommends
The one gotcha: once in a while a recommended package is actually one you need, and something breaks in a non-obvious way without it. When that happens, install it explicitly by name alongside the rest rather than dropping the flag.