'microdnf clean all' missing

ID

purge_microdnf_package_cache

Severity

low

Family

Container Security

Tags

dockerfile, non-reachable, smaller-size

Description

Cached package data should be cleaned after installation to reduce image size.

Security

N/A

Examples

FROM ubi8:8.7

# issue
RUN microdnf install -vy docker-ce zsh

HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

Mitigation / Fix

Add microdnf clean all to Dockerfile:

FROM ubi8:8.7

# fixed, no install without cleaning package cache
RUN microdnf install -vy docker-ce zsh && microdnf clean all

HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1