Make first apt example follow all best practices

This is a bit of a draft, but I came across this issue in the documentation. When I searched for `docker apt-get` I found this page and copy-pasted the first example, but then I remembered it's best practice to install all packages at once and after that clear the `lists` to minimize the image size. Putting the example with all best practices first might help newer docker users to produce smaller images.
This commit is contained in:
Duncan Ogilvie 2020-09-28 22:55:35 +02:00 committed by GitHub
parent 5652b50356
commit 62cf39dfbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -352,7 +352,8 @@ RUN apt-get update && apt-get install -y \
cvs \ cvs \
git \ git \
mercurial \ mercurial \
subversion subversion \
&& rm -rf /var/lib/apt/lists/*
``` ```
### Leverage build cache ### Leverage build cache
@ -482,7 +483,8 @@ statement. For example:
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
package-bar \ package-bar \
package-baz \ package-baz \
package-foo package-foo \
&& rm -rf /var/lib/apt/lists/*
``` ```
Using `apt-get update` alone in a `RUN` statement causes caching issues and Using `apt-get update` alone in a `RUN` statement causes caching issues and