From 34a8ab340579efb59f34d0fd018fb9808f9f704f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 2 Oct 2024 13:22:45 +0200 Subject: [PATCH] Update best-practices.md Adding `--no-install-recommends` is a common best practice and can massively reduce image sizes. Since people copy from this page it is good to add. --- .../manuals/build/building/best-practices.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/content/manuals/build/building/best-practices.md b/content/manuals/build/building/best-practices.md index 5e699a5bc6e..33cf3b0d6f3 100644 --- a/content/manuals/build/building/best-practices.md +++ b/content/manuals/build/building/best-practices.md @@ -98,7 +98,7 @@ download of base images and dependencies. ```dockerfile # syntax=docker/dockerfile:1 FROM ubuntu:24.04 -RUN apt-get -y update && apt-get install -y python +RUN apt-get -y update && apt-get install -y --no-install-recommends python3 ``` Also consider [pinning base image versions](#pin-base-image-versions). @@ -165,7 +165,7 @@ review. Adding a space before a backslash (`\`) helps as well. Here’s an example from the [buildpack-deps image](https://github.com/docker-library/buildpack-deps): ```dockerfile -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends \ bzr \ cvs \ git \ @@ -324,7 +324,7 @@ For example, you can chain commands with the `&&` operator, and use use escape characters to break long commands into multiple lines. ```dockerfile -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends \ package-bar \ package-baz \ package-foo @@ -339,7 +339,7 @@ with a pipeline operator: ```dockerfile RUN <