DEV Community

Ibrahim S
Ibrahim S

Posted on

Dockerfile | no-install

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, those Vim plugins will not be installed. Of course, installing the packages you selected can also take a while.

The command "apt-get update" doesn't actually install new versions of software. Instead, it updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.

In simple terms, the only thing apt-get update does is update the local description of what packages are available. That does not download those packages, though it just downloads the updated descriptions.

So, if you are trying to reduce the size of your docker image, then add the instruction
"RUN apt-get update && apt-get -y install --no-install-recommends" instead of "RUN apt-get update && apt-get -y install".

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay