{"id":"98e68873-7e15-45ff-920d-40c1e4a61e89","task":"Configure BuildKit garbage collection policies in buildkitd.toml for a custom Docker builder","domain":"docs.docker.com","steps":["Create a docker-container or kubernetes builder that honors BuildKit config: docker buildx create --name ci --driver docker-container --use (buildkitd.toml configuration is only honored by non-docker drivers; the default docker driver reads daemon.json instead).","Enable GC and set disk thresholds under the worker section, e.g. [worker.oci] gc = true, reservedSpace = \"10GB\", maxUsedSpace = \"100GB\", minFreeSpace = \"20%\" — values accept plain bytes, unit strings like 512MB, or percentages of total disk (reservedSpace default: 10% of disk or 10GB whichever lower; maxUsedSpace default: 60% of disk or 100GB; minFreeSpace default: 20GB).","Add ordered GC policies as [[worker.oci.gcpolicy]] blocks; policies are evaluated in sequence, most specific first, and broader rules only run if earlier ones don't reclaim enough.","Policy 1 example drops easily-regenerated cache: filters = [\"type==source.local\", \"type==exec.cachemount\", \"type==source.git.checkout\"], keepDuration = \"48h\", maxUsedSpace = \"512MB\".","Policy 2 example drops cache unused 60+ days: keepDuration = \"1440h\", reservedSpace = \"10GB\".","Restart the builder so the config takes effect (docker buildx stop then docker buildx create/inspect --bootstrap, or recreate the builder since containerized buildkitd reads config at startup).","Official docs: https://docs.docker.com/build/cache/garbage-collection/ ; https://docs.docker.com/build/builders/drivers/"],"gotchas":["buildkitd.toml uses double-equals for filters (type==source.local) while daemon.json uses single-equals (type=source.local); using the wrong operator silently matches nothing or errors.","buildkitd.toml GC supports filters like mutable/immutable that daemon.json does not.","The default docker driver completely ignores buildkitd.toml — it reads builder.gc from daemon.json; config on the wrong path does nothing.","Policies less than or equal to reservedSpace in effect keep only that amount; the very last all=true policy is the catch-all that removes any cache over the cap."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T11:32:51.853Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T11:32:51.853Z"},"url":"https://mcp.waymark.network/r/98e68873-7e15-45ff-920d-40c1e4a61e89"}