您如何查看 buildkit 构建的 docker 构建缓存?

Xav*_*nis 6 docker docker-buildkit

我已经使用新的DOCKER_BUILDKIT=1构建器构建了一个图像,特别是使用--mount=cache. 几次构建我的图像后,我注意到缓存使用量已经超过 3Gb,我想查看缓存中对象的大小,以确定是因为我缓存了太多东西还是只有多个正在存储的版本。但是,docker cli 没有任何用于探索缓存 afaict 的机制。

Ric*_*kow 1

Like other cache types, local cache gets replaced on export, by replacing the contents of the index.json file. However, previous caches will still be available in the blobs directory. These old caches are addressable by digest, and kept indefinitely. Therefore, the size of the local cache will continue to grow (see moby/buildkit#1896 for more information).
Run Code Online (Sandbox Code Playgroud)

https://docs.docker.com/build/cache/backends/local/#cache-versioning

但是,如果您确实想检查实际缓存,则可以使用--cache-to可以指定目录的选项,然后可以像在任何其他文件夹中一样查看。