Enable BuildKit by setting DOCKER_BUILDKIT=1 or by using 'docker buildx build' which uses BuildKit by default
Add '--cache-to type=registry,ref=<registry>/<image>:buildcache,mode=max' to the build command to export the full build cache (including intermediate layers) to the registry
Add '--cache-from type=registry,ref=<registry>/<image>:buildcache' to subsequent build commands so the agent pulls and reuses cached layers before building
Use 'mode=max' for the cache-to export to capture all intermediate layer caches, not just the final image layers, maximizing cache hit rate for subsequent builds
Verify cache hit rates by observing 'CACHED' lines in the BuildKit output and compare build durations between the first (cold) and subsequent (warm) runs
Known gotchas
Registry cache exports add a push step at the end of the build; if the registry is unavailable or credentials are incorrect, the build succeeds but cache is not saved, causing every subsequent CI run to start cold
mode=max exports all intermediate layers and can significantly increase registry storage usage over time; implement a cache eviction policy or use a dedicated cache repository with retention rules
The cache-to and cache-from registry must support the OCI distribution spec with blob mounting; some registries have size limits or do not support the required API endpoints for efficient cache export
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