apk-pin-versions
What it does
Section titled “What it does”Reports an apk add that names a package without a version. A package is pinned when its name has =, ~, < or > (curl=8.5.0-r0, curl~8.5) or when it is a local .apk file; a variable such as $PKGS counts as unpinned, because its content is unknown.
The values of options that take one (--virtual NAME, -t NAME, --repository URL, -X URL) are not taken for packages, and an apk add with no package is fine.
Why it matters
Section titled “Why it matters”Without a version, apk add installs whatever the Alpine repository holds on the day of the build. Rebuilding the same Dockerfile later can give an image with other package versions, and a new release that breaks your program arrives without any change on your side.
A pinned build is repeatable. The price is upkeep: when the repository replaces a version with a newer one, the build fails until you update the pin.
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-pin-versions: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line apk-pin-versions 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 | DL3018 |
full |