Create a buildx builder that supports advanced cache backends: docker buildx create --use --name ci-builder --driver docker-container
Use the registry cache backend to store layer cache in a dedicated image tag: docker buildx build --cache-to type=registry,ref=YOUR_REGISTRY/myapp:buildcache,mode=max --cache-from type=registry,ref=YOUR_REGISTRY/myapp:buildcache -t YOUR_REGISTRY/myapp:latest --push .
For GitHub Actions, use the gha cache backend to store layers in the Actions cache service: add cache-from: type=gha and cache-to: type=gha,mode=max under the build-push-action inputs
For multi-stage images, set mode=max to cache all intermediate stages, not just the final stage; mode=min (the default) only caches the final stage and misses most of the speedup
When building multi-platform images, export separate per-platform caches because BuildKit cannot merge cache manifests across platforms in a single --cache-to; use a platform-specific tag suffix (e.g., :buildcache-amd64) for each target
Verify cache effectiveness by checking build output for CACHED layer markers; a cold build with mode=max populates the cache, and subsequent builds should show most layers as CACHED
Known gotchas
The gha cache backend is limited by the GitHub Actions cache size cap (10 GB default per repo); large images may evict other workflow caches or exceed the limit, falling back to uncached builds
registry cache backend writes require push access to the registry; ensure CI credentials have push rights to the cache tag before adding --cache-to to avoid authentication failures mid-build
Using --cache-to with the default docker driver (not docker-container) is not supported; the build will silently ignore the flag without the container driver
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp