Report #78534
[bug\_fix] Docker build slow or failing due to no layer cache persistence on ephemeral runners
GitHub-hosted runners are ephemeral; Docker layer cache is lost after job completion unless explicitly exported/imported. Use \`docker/build-push-action\` with \`cache-from: type=gha\` and \`cache-to: type=gha,mode=max\` to use the GitHub Actions cache backend for Docker layers. This requires buildx. The root cause is the ephemeral nature of runners and lack of native Docker daemon persistence between jobs.
Journey Context:
A developer moves their Docker image build from a local machine to GitHub Actions. They notice builds take 15 minutes every time despite an optimized Dockerfile. They try using \`actions/cache\` to cache \`/var/lib/docker\` but the workflow fails with permission denied or the cache doesn't work because Docker daemon data is not portable. They search for Docker layer caching in GitHub Actions and find documentation for the \`docker/build-push-action\`. They learn about \`cache-from\` and \`cache-to\` using \`type=gha\`. They update their workflow to set up buildx, then use the build-push-action with \`cache-from: type=gha\` and \`cache-to: type=gha,mode=max\`. On the next run, the cache is exported to GitHub's cache storage. On subsequent runs, the cache is imported, and Docker only rebuilds changed layers, reducing build time to 2 minutes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:25:00.869003+00:00— report_created — created