docs: document tag parameter and restructure local cache versioning - #25943
docs: document tag parameter and restructure local cache versioning#25943sunm2n wants to merge 2 commits into
Conversation
Signed-off-by: Sunmin Lee <134378502+sunm2n@users.noreply.github.com>
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The ## Cache versioning
A local cache directory uses an OCI image layout. Its `index.json` file
associates tags with cache manifests, while the `blobs` directory stores the
manifest and cache data.
By default, BuildKit exports and imports the cache tagged `latest`. Use
different tags to keep multiple caches in the same directory:
```console
$ docker buildx build --cache-to type=local,dest=path/to/local/dir,tag=v1 .
$ docker buildx build --cache-to type=local,dest=path/to/local/dir,tag=v2 .
```
Exporting another cache with the same tag updates that tag to reference the new
manifest. Manifests referenced by other tags remain unchanged.
Import a cache by specifying its tag:
```console
$ docker buildx build --cache-from type=local,src=path/to/local/dir,tag=v1 .
```
A digest identifies an exact cache manifest. Use `digest` instead of `tag` when
you need a specific manifest:
```console
$ docker buildx build \
--cache-from type=local,src=path/to/local/dir,digest=sha256:<DIGEST> .
```
If you specify both `digest` and `tag`, BuildKit uses `digest`.
By default, updating a tag doesn't delete the blobs used by its previous
manifest. The previous manifest remains available by digest, so the local cache
directory grows over time.This would also remove the large Generated by Codex |
Rewrite the section around how tags, digests, and stored blobs relate, as suggested in review. Also corrects two errors in the existing text: - The digest import example used ref=, which fails with "local cache importer requires src". The parameter is src=. - The text said cache gets replaced on export by replacing index.json. Since moby/buildkit#3111, index.json merges: exporting a new tag keeps manifests referenced by other tags. Drops the moby/buildkit#1896 reference, which is closed as completed. Signed-off-by: Sunmin Lee <134378502+sunm2n@users.noreply.github.com>
|
Restructured the section as suggested. I verified the behavior against BuildKit before rewriting, and the checks turned up two errors in the existing text that the restructure now fixes:
"local cache gets replaced on export" is no longer accurate. Since moby/buildkit#3111, $ docker buildx build --cache-to type=local,dest=./cache,tag=v1 .
$ docker buildx build --cache-to type=local,dest=./cache,tag=v2 .
$ jq -r '.manifests[].annotations."org.opencontainers.image.ref.name"' cache/index.json
v1
v2I think this is what made the section hard to follow — it contradicted the tag behavior being documented directly above it. I also dropped the One addition to your draft: the digest example had no way to obtain Separately, moby/buildkit#6612 added a |
Description
The
tagparameter for thelocalcache backend was added inmoby/buildkit#3111 but was
never documented. The page also carried a
FIXMEcomment waiting on thatPR, which has long since been released.
Changes:
tagto the parameter tableFIXMEcommentVerified against
client/solve.goand by running builds locally:org.opencontainers.image.ref.name,defaulting to
latest--cache-fromwith a matching tag restores the cache on a fresh builderdigestis set,tagis ignoredReviews