Description
FlagsRUN instructions that install dependencies or build artifacts with package managers but do not use cache mounts.
The rule follows Docker’s official cache-mount guidance in the Use cache mounts section:
It also supports pnpm, uv, and bun package install flows.
Each suggested mount includes an id for observability and reusability across build stages.
Detected Commands and Cache Targets
Cache path resolution from environment variables
The rule resolves custom cache paths fromENV instructions in the Dockerfile:
If the variable value contains
$ (unresolved shell reference), the override is skipped.
Examples
Before (violation)
After (fixed with —fix —fix-unsafe)
pnpm with PNPM_HOME
Heredoc RUN support
What this rule removes (and why)
This cleanup only happens when the fix adds cache mounts for the related package manager. The motivation is simple: these commands/flags either delete local package caches or explicitly disable caching, which cancels out the speed benefits of cache mounts.Cache-cleaning commands removed
- apt/apt-get:
apt-get clean,apt clean, andrm -rf /var/lib/apt/lists* - apk:
apk cache clean ...andrm -rf /var/cache/apk* - dnf:
dnf clean ...andrm -rf /var/cache/dnf* - yum:
yum clean ...andrm -rf /var/cache/yum* - zypper:
zypper clean ...andrm -rf /var/cache/zypp* - npm:
npm cache clean ... - pnpm:
pnpm store prune - pip:
pip cache purge,pip cache remove ... - bundle:
bundle clean ... - yarn:
yarn cache clean ... - dotnet:
dotnet nuget locals ... --clear - composer:
composer clear-cache,composer clearcache - uv:
uv cache clean,uv cache prune - bun:
bun pm cache rm,bun pm cache clean
Cache-disabling flags removed
- apk:
--no-cache - pip:
--no-cache-dir - uv:
--no-cache - bun:
--no-cache
Cache-disabling environment variables removed
- pip:
ENV PIP_NO_CACHE_DIR=...(the entireENVinstruction is removed if it only setsPIP_NO_CACHE_DIR; otherwise, only thePIP_NO_CACHE_DIRvariable is removed) - uv:
ENV UV_NO_CACHE=...(the entireENVinstruction is removed if it only setsUV_NO_CACHE; otherwise, only theUV_NO_CACHEvariable is removed)