Skip to content

zypper-clean

Dockerfileperformanceno fixdefault: offdockerfile/hadolint

Reports a RUN that installs with zypper and does not clean the cache. It runs zypper install (in) and has no zypper clean or zypper cc after it in the same RUN. A RUN with a --mount of type cache or tmpfs on /var/cache/zypp is not reported.

zypper install stores the metadata and packages it downloaded under /var/cache/zypp. 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
...
RUN dnf install -y curl-7.0 && dnf clean all
...
RUN zypper install curl
RUN zypper install -y curl=7.0 && zypper clean
RUN zypper install -y curl
...
RUN zypper -n in curl=1 && zypper cc
dockerfile:
lint:
rules:
zypper-clean: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line zypper-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 DL3036 full