Skip to content
Latchkey

apt-get install --no-install-recommends: Usage & CI Errors

--no-install-recommends installs only hard dependencies, leaving out "nice to have" extras.

On Debian/Ubuntu, packages declare Recommends (suggested companions) that apt installs by default. In CI Docker builds, --no-install-recommends is the standard way to keep image layers small.

What it does

By default apt installs Depends and Recommends. --no-install-recommends installs only the strict Depends, omitting the recommended set. This can cut hundreds of megabytes from an image (docs, optional plugins, extra runtimes) but occasionally drops something a tool actually needs at runtime.

Common usage

Terminal
apt-get install -y --no-install-recommends git ca-certificates
# make it the default for the whole image:
echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/00recommends
apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*

Common errors in CI

The trade-off shows up later: a tool fails at runtime with a missing helper that was a Recommends (e.g. git without ca-certificates can hit "server certificate verification failed", or a package that recommended a fonts/locale dependency). The fix is to add the now-missing package explicitly to the install line rather than dropping the flag. Pair it with rm -rf /var/lib/apt/lists/* in the same RUN layer so the index cache does not bloat the image.

Options

Flag / settingWhat it does
--no-install-recommendsSkip Recommends for this install
--no-install-suggestsSkip Suggests as well (default off)
APT::Install-Recommends "false"Make it the default in apt.conf.d
-yAssume yes (required in CI)

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →