Ensure 'dnf clean' after 'dnf install' for image storage space saving

dnf clean command removes unneeded files that take storage space and affect your final image size. The size reduction can be surprisingly significant.

Risk Level: medium
Platform: Docker
Spectral Rule ID: DOCKR024

REMEDIATION

Append each dnf install with dnf clean or append the last dnf install with dnf clean all.

FROM fedora:27
RUN set -uex && \
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
sed -i 's/\$releasever/26/g' /etc/yum.repos.d/docker-ce.repo && \
- dnf install -vy docker-ce
+ dnf install -vy docker-ce && \
+ dnf clean all
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

Read more: