Skip to content

gem-pin-versions

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a gem install (or gem i) of a gem without a version: rails instead of rails:7.1.3. -v or --version pins as well. The values of options that take one (--source URL, -i DIR, --platform NAME) are not taken for gems.

Without a version gem install takes the newest release on the day of the build, and so a major release of a gem can break the image, and two builds of one Dockerfile give different results.

Reported
...
RUN npm install ./local
...
RUN npm add express@4
RUN gem install rails
RUN gem install --no-document rails
RUN gem install --source https://rubygems.org rails:7.0
RUN gem install rails:7.0
RUN gem install rails -v 7.0
...
dockerfile:
lint:
rules:
gem-pin-versions: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line gem-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 DL3028 partial hadolint drops the word after every flag; Sudsy does the same (skip-flag-args: *), so cases it parses differently with options can differ.