shlogg · Early preview
Ibrahim S @ibrahimsi

Reduce Docker Image Size With APT Flags

Use `apt-get update && apt-get -y install --no-install-recommends` in Dockerfile to avoid installing recommended packages & reduce image size. This command updates package lists & installs selected packages without recommended ones.

Why should we not simply use the instruction "RUN apt-get update && apt-get -y install" in our Dockerfile? 👨🏻‍💻
To avoid the installation of recommended packages and to reduce the size of your Docker image, we should include the flag "--no-install-recommends" when using APT in our Dockerfile.
Command "apt-get install" installs packages. To install those packages, it needs to download them. 
Using --no-install-recommends tells apt-get to not install "recommended packages." 
For example, if you install Vim, many plugins are also recommended and provided as separate packages. With that switch,...