Report #90241
[bug\_fix] E: Unable to locate package during RUN apt-get install, even though the package exists in the repository
Combine \`apt-get update\` and \`apt-get install\` in a single \`RUN\` instruction \(e.g., \`RUN apt-get update && apt-get install -y \`\).
Journey Context:
A developer builds an image and it works. A week later, the build breaks with 'Unable to locate package'. They didn't change the Dockerfile. They assume the upstream repository is down and try again later, but it persists. They learn that if \`apt-get update\` is in one \`RUN\` step and \`apt-get install\` is in another, Docker caches the \`apt-get update\` layer. When a new package is added to the install step, Docker re-runs the install step but uses the cached \(stale\) package index from the previous \`update\` step, causing the new package to not be found. Combining them into a single \`RUN\` using \`&&\` ensures that if the install list changes, the update step is also invalidated and re-run, fetching the fresh index.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:03:51.273956+00:00— report_created — created