Ensure disabling recommended package in apt-get (--no-install-recommends)

The recommended and suggested packages are not essential, and they are there to offer some extra functionality that we might not need to use. By default apt will install required and recommended packages. For reduced the size of Docker container significantly, avoid the installation of recommended packages including the flag --no-install-recommends when using apt in our Dockerfile.

Risk Level: informational
Platform: Docker
Spectral Rule ID: DOCKR008

REMEDIATION

Use --no-install-recommends flag in each use of apt-get install. If you want these flags to always be enabled put the following line in /etc/apt/apt.conf' file: APT::Get::Install-Recommends "false";

- RUN apt-get update && apt-get install --yes python3
+ RUN apt-get update && apt-get install --no-install-recommends --yes python3

Read more: