| Property | Value |
|---|---|
| Severity | Style |
| Category | Style |
| Default | Enabled |
| Auto-fix | Yes (safe) |
Description
Whenever possible, multi-line arguments should be sorted alphanumerically to make maintenance easier. This helps to avoid duplication of packages and makes the list much easier to update. This also makes PRs a lot easier to read and review. This rule enforces the official Docker best practice for sorting package lists across common package manager install commands.Supported Package Managers
| Manager | Install subcommands |
|---|---|
| apt-get, apt | install |
| apk | add |
| dnf, yum | install |
| zypper | install, in |
| npm | install, i, add |
| yarn | add |
| pnpm | add, install, i |
| pip, pip3 | install |
| bun | add, install, i |
| composer | require |
| uv | add, pip install |
| choco | install |
Sort key extraction
Version specifiers are stripped for comparison:flask==2.0sorts asflaskcurl=7.88.1-10+deb12u5sorts ascurl@eslint/js@8.0.0sorts as@eslint/js(npm scoped package)
Variable arguments
When install commands mix literal packages and variable references ($PKG, ${PKG}), only the literal packages are sorted. Variables are kept at the
end in their original relative order. Variable tokens are never touched by edits, avoiding conflicts with other rules like ShellCheck quoting.
Skipped cases
No violation is emitted when:- Fewer than 2 literal packages (nothing to sort)
- File-based install:
pip install -r requirements.txt,pip install -e . - All arguments are variables
- Exec-form RUN:
RUN ["apt-get", "install", "curl"] - Packages are already sorted