Skip to content

apt-get-pin-versions

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports an apt-get install of a package without a version. A package is pinned when its name has = (curl=7.88.1-10) or / (curl/stable, a release), or when it is a .deb file. The value of -t or --target-release is not taken for a package. A variable such as $PKGS counts as unpinned.

An unpinned install takes the newest version the distribution offers on the day of the build. Two builds of one Dockerfile can then differ, and a new release can break the image without any change in your code.

Pinned versions make the build repeatable. Debian and Ubuntu remove old versions from their repositories, so a pin stops resolving after a while and needs updating.

Reported
FROM debian:12
RUN apt-get update && apt-get install curl
...
RUN apt-get install -y --no-install-recommends curl
...
RUN apt-get install --yes \
curl \
git
RUN apt-get update
...
dockerfile:
lint:
rules:
apt-get-pin-versions: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line apt-get-pin-versions in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL3008 full