For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/dockerfile-update-instruction-alone.md.
A documentation index is available at /llms.txt.
Separating a package index update from the package installation across multiple Dockerfile RUN instructions can cause builds to use cached layers and install packages from stale indexes. This increases the risk of including outdated or vulnerable package versions in the image.
This check examines Dockerfile RUN commands (resources where Cmd == "run" and Value contains the command string) and verifies that when a package-manager updater is invoked (examples: apt-get update, apt update, apk update, yum update, dnf update, zypper refresh, pacman -Syu) it is followed in the same RUN statement by the corresponding installer command (for example, apt-get install/apt install, apk add, yum install, dnf install, zypper install, and pacman -S). Resources that run an update without an install in the same RUN, or that place the install in a later RUN instruction, will be flagged.
Secure examples that combine update and install in one RUN: