Review zypper cache cleanup

Complete installation and zypper cache cleanup in the same RUN.

Description

After zypper install, downloaded packages and repository metadata can remain in the image.

Potential impact

Unused files increase image size and transfer time. Deleting them in a later layer leaves the installation layer intact.

Remediation

Run zypper clean in the same RUN after installation succeeds. Use zypper clean --all to remove repository metadata as well. Check what remains in the final image.

Examples

The openSUSE Leap 15.6 example clears the package cache. Use a supported base and repositories for production builds.

Before

dockerfile
FROM opensuse/leap:15.6

RUN zypper install -y nginx

After

dockerfile
FROM opensuse/leap:15.6

RUN zypper install -y nginx \
    && zypper clean

References