pip-pin-versions
What it does
Section titled “What it does”Reports a pip install (also pip3, pip3.12) of a package without a version. A package is pinned when it has a specifier (==, >=, <, !=, ~=) or is a wheel, a source archive or a path (.whl, .tar.gz, anything with a /). A VCS requirement such as git+https://example.com/x.git must name a revision after @.
Not reported: pip install -r requirements.txt and -c constraints.txt (the versions are in the file), pip install ., and the values of options such as -i, -e or -t. python -m pip install and pipenv are not checked.
Why it matters
Section titled “Why it matters”An unpinned pip install takes the latest release of the package, and of the libraries it depends on, on the day of the build. A new major version can break the application, and two builds of one Dockerfile give different images.
Pin the packages, ideally in a requirements.txt made by a lock tool, and install it with -r.
Example
Section titled “Example”FROM node:20RUN pip install flaskRUN pip install flask==2.0 "requests>=2"RUN pip3 install -r requirements.txtRUN pip install --no-cache-dir -i https://x/simple flask==1RUN pip install .RUN pip install git+https://github.com/a/bRUN pip install git+https://github.com/a/b@v1RUN npm install...Configuration
Section titled “Configuration”dockerfile: lint: rules: pip-pin-versions: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line pip-pin-versions in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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 | DL3013 |
partial | python -m pip install and the wrappers (pipx, pipenv) are not told apart as hadolint does. |