Report #96725
[bug\_fix] RUN apt-get install -y fails with 'Unable to locate package', despite apt-get update running in a previous layer.
Combine apt-get update and apt-get install into a single RUN statement \(e.g., RUN apt-get update && apt-get install -y \).
Journey Context:
A developer builds an image successfully. Weeks later, they add a new package to the apt-get install list, but the build fails, claiming the package doesn't exist. They are confused because apt-get update is clearly in the Dockerfile. They investigate and learn that Docker layer caching cached the apt-get update layer from weeks ago. When the apt-get install layer is invalidated by the new package name, it runs against the stale cached update metadata, which no longer points to the current repository manifests. Combining them into a single RUN command ensures they are part of the same layer, so any change to the install list forces a fresh update.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:56:19.219156+00:00— report_created — created