DL3019: Use the --no-cache switch for apk add
Info Efficiency
Why This Matters
Without --no-cache, apk stores a local package index in /var/cache/apk/ that adds unnecessary size to Alpine-based images. Alpine images are chosen specifically for their small footprint (5 MB base), so leaving the apk cache around undermines that advantage. Use --no-cache to avoid storing the index entirely.
How to Fix
Add --no-cache to apk add
Before (incorrect)
RUN apk update && apk add curl After (correct)
RUN apk add --no-cache curl Rule Details
- Rule Code
- DL3019
- Severity
- Info
- Category
- Efficiency