apk-no-cache
What it does
Section titled “What it does”Reports an apk add without the --no-cache flag. A RUN with a --mount of type cache or tmpfs on /var/cache/apk is not reported, since nothing is stored in the image there.
Why it matters
Section titled “Why it matters”Without --no-cache, apk add keeps the downloaded package index in /var/cache/apk. That copy is written into the layer and stays in the image, making it larger for data nobody reads at run time.
--no-cache fetches the index for this one command and stores nothing; it replaces the older pair apk update and rm -rf /var/cache/apk/*.
Example
Section titled “Example”FROM alpine:3RUN apk add curlRUN apk add --no-cache curl=8.5.0-r0RUN apk add --no-cache --virtual .deps gcc=13.2.1-r0 musl-dev=1.2.4-r2RUN apk add --no-cache ./pkg.apk...Configuration
Section titled “Configuration”dockerfile: lint: rules: apk-no-cache: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line apk-no-cache in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3019 |
full |