zypper-clean
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”...RUN dnf install -y curl-7.0 && dnf clean all...RUN zypper install curlRUN zypper install -y curl=7.0 && zypper cleanRUN zypper install -y curl...RUN zypper -n in curl=1 && zypper ccConfiguration
Section titled “Configuration”dockerfile: lint: rules: zypper-clean: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line zypper-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 | DL3036 |
full |