@@ -137,8 +137,14 @@ $ docker buildx imagetools inspect <IMAGE>@sha256:d20246ef744b1d05a1dd69d0b3fa90
137
137
## Specify annotation level
138
138
139
139
By default, annotations are added to the image manifest. You can specify which
140
- level(s) to attach the manifest to, by prefixing the annotation string with a
141
- special type declaration:
140
+ level (OCI image component) to attach the annotation to by prefixing the
141
+ annotation string with a special type declaration:
142
+
143
+ ``` console
144
+ $ docker build --annotation " <TYPE>:<KEY>=<VALUE>" .
145
+ ```
146
+
147
+ The following types are supported:
142
148
143
149
- ` manifest ` : annotates manifests.
144
150
- ` index ` : annotates the root index.
@@ -152,17 +158,34 @@ image index:
152
158
$ docker build --tag < IMAGE> --push --annotation " index:foo=bar" .
153
159
```
154
160
155
- It's possible to specify types, separated by a comma, to add the annotation to
161
+ Note that the build must produce the component that you specify, or else the
162
+ build will fail. For example, the following does not work, because the ` docker `
163
+ exporter does not produce an index:
164
+
165
+ ``` console
166
+ $ docker build --output type=docker --annotation " index:foo=bar" .
167
+ ```
168
+
169
+ Likewise, the following example also does not work, because buildx creates a
170
+ ` docker ` output by default under some circumstances, such as when provenance
171
+ attestations are explicitly disabled:
172
+
173
+ ``` console
174
+ $ docker build --provenance=false --annotation " index:foo=bar" .
175
+ ```
176
+
177
+ It is possible to specify types, separated by a comma, to add the annotation to
156
178
more than one level. The following example creates an image with the annotation
157
179
` foo=bar ` on both the image index and the image manifest:
158
180
159
181
``` console
160
182
$ docker build --tag < IMAGE> --push --annotation " index,manifest:foo=bar" .
161
183
```
162
184
163
- You can also specify a platform qualifier in the type prefix, to annotate only
164
- components matching specific OS and architectures. The following example adds
165
- the ` foo=bar ` annotation only to the ` linux/amd64 ` manifest:
185
+ You can also specify a platform qualifier within square brackets in the type
186
+ prefix, to annotate only components matching specific OS and architectures. The
187
+ following example adds the ` foo=bar ` annotation only to the ` linux/amd64 `
188
+ manifest:
166
189
167
190
``` console
168
191
$ docker build --tag < IMAGE> --push --annotation " manifest[linux/amd64]:foo=bar" .
0 commit comments