yum package versions are not pinned

Installing yum packages without versions can change the contents of a Docker build.

Description

yum install httpd uses the version available from the repository at build time. A repository update can change what the same Dockerfile installs.

Potential impact

If a rebuilt deployment image behaves differently from the tested image, it can be harder to reproduce a failure or roll back.

Remediation

  • Specify an exact version and release available in the repository, as in yum install -y httpd-<version>-<release>. Supply an equally precise value when using a variable.
  • Test the updated package and check its security before changing the pin.

Examples

These are installation excerpts for a supported image that provides yum. Supply a reviewed version-release available in that image’s repository through HTTPD_VERSION_RELEASE. Manage pinning and security updates for other packages and the base image separately.

Before

dockerfile
RUN yum install -y httpd && yum clean all
RUN ["yum", "install", "httpd"]

After

dockerfile
ARG HTTPD_VERSION_RELEASE
RUN test -n "$HTTPD_VERSION_RELEASE" && yum install -y "httpd-${HTTPD_VERSION_RELEASE}" && yum clean all

Explanation:

  • Before: Neither the shell nor the JSON form specifies an httpd version.
  • After: Installation requires HTTPD_VERSION_RELEASE and requests that exact httpd version and release.

References