Docker Community Forums

Share and learn in the Docker community.

How to delete build cache (buildkit experimental)

When using the experimental docker buildkit features:

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

1 Like

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.