When using the experimental docker buildkit features: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md
Specifically: RUN --mount=type=cache,target=/root/mycache ....
How do I clean up (delete) this cache mount when I want to trigger a fresh build?
I would assume there would be a command similar to “docker volume rm” but the cache mounts don’t
appear in docker volume ls
.
docker builder prune --filter type=exec.cachemount
2 Likes
Thanks @tonistiigi this works great.
I used a different filter to target a specific id: docker builder prune --filter id=......
Is there a way to give the cache a name so that I can more easily target it? The documentation says that there is an optional ID I can pass but when I do:
RUN --mount=id=my-project-cache,type=cache,target=/path/to/dir
nothing changes, that is when using docker system df -v
the cache id is still a random string.
Is it possible to get a reply here @tonistiigi ? It’s still a problem in 2023.
@tonistiigi It looks like someone may be taking this on?
opened 10:35PM - 29 Jun 23 UTC
kind/enhancement
area/cache
area/cli
### Description
Following up from: https://github.com/docker/buildx/issues/931
…
1. Why can't we have something like, `docker buildx du --filter /var/cache/apt`? It would allow direct inspecting/clearing of cache mounts. I'm writing some logic to allow deleting of a particular build cache mount if desired. I'm not able to have a clear script for this because of the current support.
2. Is it also possible to add more details with `docker buildx du --verbose --filter type=exec.cachemount` in order to know which image that particular cache mount is associated with? I don't even understand why there is an "id" field configurable if you can't key off of it in any way. I just changed one of the mounts for a java program's .m2 directory and all I get is 3 entries here and none of them discernable.
```
~ ❯ docker buildx du --verbose --filter type=exec.cachemount | grep -B 6 -F "/root/.m2" 06:28:51 PM
ID: qd98bx4cmfe7de8fln5nx65ut
Created at: 2023-06-29 21:09:39.551389639 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 19.31MB
Description: cached mount /root/.m2 from exec /bin/sh -c ./mvnw test
--
ID: glydhkz1vo25rado1zoq7ajbs
Created at: 2023-06-29 21:35:45.00107996 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 1.897MB
Description: cached mount /root/.m2 from exec /bin/sh -c ./mvnw dependency:resolve-plugins
--
ID: 2iq3u28y28xlsagy1esqkpfu6
Created at: 2023-06-29 22:30:07.203308554 +0000 UTC
Mutable: true
Reclaimable: false
Shared: false
Size: 0B
Description: cached mount /root/.m2 from exec /bin/sh -c ./mvnw dependency:resolve-plugins
```