DL3009: Delete the apt-get lists after installing
Info Efficiency
Why This Matters
After apt-get update && apt-get install, the package lists in /var/lib/apt/lists/ remain in the image layer, adding 20-40 MB of unnecessary data. This bloats your image and slows down container pulls across your cluster. Always remove apt lists in the same RUN instruction to keep the layer lean.
How to Fix
Add rm -rf /var/lib/apt/lists/* in the same RUN instruction
Before (incorrect)
RUN apt-get update && apt-get install -y curl After (correct)
RUN apt-get update && apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/* Rule Details
- Rule Code
- DL3009
- Severity
- Info
- Category
- Efficiency