yum-clean
What it does
Section titled “What it does”Reports a RUN that installs with yum and does not clean the cache. It runs yum install and has no yum clean all after it in the same RUN. An rm -rf /var/cache/yum/* written exactly so is accepted as well.
Why it matters
Section titled “Why it matters”yum install stores the metadata and packages it downloaded under /var/cache/yum. That cache is written into the layer and stays in the image, adding size that nothing uses at run time.
Clean it in the same RUN: a later RUN cannot shrink a layer that was already written.
Example
Section titled “Example”FROM fedora:40RUN yum install curlRUN yum install -y curl-7.0 && yum clean allRUN yum install -y curl-7.0 && rm -rf /var/cache/yum/*RUN yum install -y nginx-1.2 && yum clean all...Configuration
Section titled “Configuration”dockerfile: lint: rules: yum-clean: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line yum-clean in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3032 |
full |