For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/dockerfile-unpinned-package-version-in-apk-add.md.
A documentation index is available at /llms.txt.
Alpine packages installed in Dockerfile RUN instructions should be version-pinned to prevent supply-chain risks and ensure reproducible builds. Unpinned packages can pull in newer, potentially vulnerable or incompatible versions on rebuilds.
This rule inspects Dockerfile RUN instructions that invoke apk add and requires each package token to use the pinning form package=version. Flags such as --virtual, -t, and short options like -v are ignored when identifying package names. Alphabetic tokens following apk add that are not option flags and do not include =version will be flagged.
Resources with packages like apk add curl (no version) will be reported. Update RUN lines to pin package versions.
Secure example:
RUN apk add --no-cache ca-certificates=20210512curl=7.79.1