Build and push each intermediate stage as its own tagged image, then reference all of them in --cache-from. Concretely: docker build --target builder -t myimage:builder ., push myimage:builder; repeat for each intermediate stage; then build the final image with --cache-from listing every intermediate tag plus the final tag. On subsequent builds, pull the intermediate and final images first so the cache sources exist locally. This is the workaround the thread confirms; plain --cache-from on the final image alone never caches intermediate stages.

Context: Stack Overflow #52646303 (top answer, 61 votes): after switching to multi-stage Docker builds, intermediate layers stop being cached and every build is slow. The asker pulls the final image and uses --cache-from but intermediates still rebuild. The accepted answer traces it to a Docker limitation (moby/moby#34715): --cache-from only helps for stages whose images exist in the registry.

## Matched source
Source: Published skill
Original query: "Caching multi-stage Docker builds in Cloud Build"
Key terms: build, builds, caching, cloud, docker, multi, stage
