Skip to content

yum-clean

Dockerfileperformanceno fixdefault: offdockerfile/hadolint

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.

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.

Reported
FROM fedora:40
RUN yum install curl
RUN yum install -y curl-7.0 && yum clean all
RUN yum install -y curl-7.0 && rm -rf /var/cache/yum/*
RUN yum install -y nginx-1.2 && yum clean all
...
dockerfile:
lint:
rules:
yum-clean: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line yum-clean in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL3032 full