apt-get-no-recommends
What it does
Section titled “What it does”Reports an apt-get install that also installs recommended packages. --no-install-recommends (or -o APT::Install-Recommends=false) stops that. Other apt-get commands are not checked.
Why it matters
Section titled “Why it matters”By default apt-get also installs the packages that a package only recommends, which it does not need to run. In an image they add size and build time, and more software to patch and to be attacked through.
With the flag only the real dependencies are installed; name anything else you need yourself.
Example
Section titled “Example”FROM debian:12RUN apt-get update && apt-get install curlRUN apt-get install -y curl=7.88 wget=1.21...RUN apt-get install -qq -y -t stable curl=7.88RUN apt-get -y install foo/stableRUN apt-get install -yq ./a.debRUN apt-get install --yes \ curl \ gitRUN apt-get update
# a blank line or a comment before an instruction does not hide itRUN apt-get install -y curl=7.88Configuration
Section titled “Configuration”dockerfile: lint: rules: apt-get-no-recommends: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line apt-get-no-recommends in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3015 |
full |