Report #9438
[bug\_fix] Docker layer caching not persisting between workflow runs despite using cache-to/cache-from with type=gha
Explicitly set \`cache-to: type=gha,mode=max\` \(and \`cache-from: type=gha\`\) in the \`docker/build-push-action\` inputs. The default \`mode=min\` only caches the final image layers, missing intermediate build stages; \`mode=max\` is required to cache all layers including those from multi-stage builds. Additionally, for matrix builds, specify unique \`scope\` values to prevent cache collisions between parallel jobs.
Journey Context:
A developer configures Docker layer caching in their workflow using \`docker/build-push-action\`. They set \`cache-from: type=gha\` and \`cache-to: type=gha\` expecting fast builds on subsequent runs. However, the build still takes 10 minutes and logs show 'exporting cache' but no 'importing cache' or cache hits. They check the documentation and realize that by default, \`mode\` is \`min\`, which only exports the final image layers, not the intermediate layers from their multi-stage Dockerfile \(builder stage\). They change \`cache-to\` to \`type=gha,mode=max\`. In a subsequent run, they see 'importing cache' and the build completes in 2 minutes because the heavy builder stage layers were restored. Later, they add a build matrix for multiple platforms and notice intermittent cache misses; they learn to add \`scope: $\{\{ matrix.platform \}\}\` to isolate the cache scopes per matrix job to prevent collisions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:12:25.913667+00:00— report_created — created