Skip to content

Files

Latest commit

 

History

History
28 lines (18 loc) · 869 Bytes

DL3009.md

File metadata and controls

28 lines (18 loc) · 869 Bytes

Pattern: Missing cleanup for apt-get

Issue: -

Description

Cleaning up the apt cache and removing /var/lib/apt/lists helps keep the image size down. Since the RUN statement starts with apt-get update, the package cache will always be refreshed prior to apt-get install.

Clean up must be performed in the same RUN step, otherwise it will affect image size.

Example of incorrect code:

RUN apt-get update && apt-get install -y python

Example of correct code:

RUN apt-get update && apt-get install -y python \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

Further Reading