Skip to content

rpm-pin-versions

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a yum install, dnf install or microdnf install of a package without a version. A package is pinned when it is written name-version (curl-7.88.1: a digit after a dash), is a .rpm file or contains a variable. Commands with module or group are not checked.

An unpinned install takes the newest version in the enabled repositories 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. Repositories drop old versions, so a pin needs updating from time to time.

Reported
FROM fedora:40
RUN yum install curl
RUN yum install -y curl-7.0 && yum clean all
RUN yum install -y curl-7.0 && rm -rf /var/cache/yum/*
RUN yum install -y nginx-1.2 && yum clean all
RUN dnf install curl
...
RUN dnf install -y curl-7.0 && dnf clean all
...
RUN dnf install -y ./a.rpm && dnf clean all
...
RUN zypper install -y curl=7.0 && zypper clean
...
dockerfile:
lint:
rules:
rpm-pin-versions: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

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

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
hadolint DL3033 partial A variable in a package counts as pinned; hadolint checks that an ENV or ARG defines it.
hadolint DL3041 partial A variable in a package counts as pinned; hadolint checks that an ENV or ARG defines it.