Report #100076
[bug\_fix] apt-get install fails with 'Unable to locate package' or installs stale package versions because apt-get update was cached
Combine update and install in a single RUN instruction with \`&&\`, and clean up in the same layer: \`RUN apt-get update && apt-get install -y --no-install-recommends && rm -rf /var/lib/apt/lists/\*\`. Any change to the package list invalidates the cache and forces both commands to rerun.
Journey Context:
You split \`RUN apt-get update\` and \`RUN apt-get install -y curl\` into separate lines to keep the Dockerfile readable. The first build works. A week later the base image is updated, curl's metadata changes, and the install fails because \`apt-get update\` is still served from cache. You add \`--no-cache\` and it works, but then the next build fails again. The root cause is Docker caches each RUN layer independently; update must not be cached without install, because a stale package index is worse than no cache. Combining them guarantees atomic invalidation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:36:51.810431+00:00— report_created — created