$ docker buildx imagetools inspect <IMAGE>@sha256:d20246ef744b1d05a1dd69d0b3fa907db007c07f79fe3e68c17223439be9fefb --raw
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"digest": "sha256:4368b6959a78b412efa083c5506c4887e251f1484ccc9f0af5c406d8f76ece1d",
"size": 850
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:2c03dbb20264f09924f9eab176da44e5421e74a78b09531d3c63448a7baa7c59",
"size": 3333033
},
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:4923ad480d60a548e9b334ca492fa547a3ce8879676685b6718b085de5aaf142",
"size": 61887305
}
],
"annotations": {
"index,manifest:org.opencontainers.image.vendor": "foocorp",
"org.opencontainers.image.source": "https://git.example/foo.git",
}
}
```
## Specify annotation level
By default, annotations are added to the image manifest. You can specify which
level (OCI image component) to attach the annotation to by prefixing the
annotation string with a special type declaration:
```console
$ docker build --annotation "<TYPE>:<KEY>=<VALUE>" .
```
The following types are supported:
- `manifest`: annotates manifests.
- `index`: annotates the root index.
- `manifest-descriptor`: annotates manifest descriptors in the index.
- `index-descriptor`: annotates the index descriptor in the image layout.
For example, to build an image with the annotation `foo=bar` attached to the
image index:
```console
$ docker build --tag <IMAGE> --push --annotation "index:foo=bar" .
```
Note that the build must produce the component that you specify, or else the
build will fail. For example, the following does not work, because the `docker`
exporter does not produce an index:
```console
$ docker build --output type=docker --annotation "index:foo=bar" .
```
Likewise, the following example also does not work, because buildx creates a
`docker` output by default under some circumstances, such as when provenance
attestations are explicitly disabled:
```console
$ docker build --provenance=false --annotation "index:foo=bar" .
```
It is possible to specify types, separated by a comma, to add the annotation to
more than one level. The following example creates an image with the annotation
`foo=bar` on both the image index and the image manifest:
```console
$ docker build --tag <IMAGE> --push --annotation "index,manifest:foo=bar" .
```
You can also specify a platform qualifier within square brackets in the type
prefix, to annotate only components matching specific OS and architectures. The
following example adds the `foo=bar` annotation only to the `linux/amd64`
manifest:
```console
$ docker build --tag <IMAGE> --push --annotation "manifest[linux/amd64]:foo=bar" .
```
## Related information
Related articles:
- [Add image annotations with GitHub Actions](/manuals/build/ci/github-actions/annotations.md)
- [Annotations OCI specification][specification]
Reference information:
- [`docker buildx build --annotation`](/reference/cli/docker/buildx/build.md#annotation)
- [Bake file reference: `annotations`](/manuals/build/bake/reference.md#targetannotations)
- [`docker buildx imagetools create --annotation`](/reference/cli/docker/buildx/imagetools/create.md#annotation)
<!-- links -->