Impact & Risk Analysis
- Severity: Medium
- CIS Benchmark: CIS 4.7
- Impact: Stale Package Cache. Adding update instructions (like
apt-get update) in a single line causes the update layer to be cached. If you build the image later, Docker reuses this cached layer, meaning your package lists are not refreshed. This can prevent fresh security updates from being applied or cause build failures if the referenced package version no longer exists in the repository.
Common Misconfiguration
Using OS package manager update instructions (such asapt-get update or yum update) alone or in a distinct RUN instruction separate from the installation command.
Vulnerable Example
Secure Example
Audit Procedure
Step 1: Run the command below to get the list of images:Remediation
You should use update instructions together with install instructions and version pinning for packages while installing them. This will prevent caching and force the extraction of the required versions. Alternatively, you could use the--no-cache flag during the docker build process to avoid using cached layers:

