Skip to content

Commit ad809fa

Browse files
Merge pull request linuxkit#3570 from deitch/doc-signing
describe how to sign tags manually
2 parents fe2ca14 + 34373e3 commit ad809fa

File tree

1 file changed

+246
-0
lines changed

1 file changed

+246
-0
lines changed

docs/packages.md

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,252 @@ pkg:
172172
content-trust-passphrase-command: "lpass show <key> --password"
173173
```
174174

175+
#### Signing Manually
176+
177+
If, for whatever reason, you want to sign an individual tag manually, whether the index (a.k.a. "multi-arch manifest") or the architecture-specific manifest, do the following:
178+
179+
1. Make sure you have ready your credentials:
180+
* docker hub login and passphrase
181+
* docker notary signing key passphrase
182+
1. Get the following information:
183+
* the name of the image repository you want to sign, including the registry host but **not** including the tag, e.g. `linuxkit/containerd`
184+
* the tag of the image you want to sign, e.g. `a4aa19c608556f7d786852557c36136255220c1f` or `v5.0`
185+
* the size of the image you want to sign in bytes, e.g. `1052`. See below for information on how to get this.
186+
* the hash of the manifest or index to which the tag points, **not** including the `sha256:` leader, e.g. `66b3d74aeb855f393ddb85e7371a00d5f7994cc26b425825df2ce910583d74dc`. See below for information on how to get this.
187+
1. Set env vars with the following:
188+
* `IMAGE`: name of the image, e.g. `IMAGE=docker.io/linuxkit/containerd`
189+
* `TAG`: the tag you want to sign. It could be a tag pointing at a multi-arch manifest or tag pointing at an individual architecture's manifest, e.g. `TAG=a4aa19c608556f7d786852557c36136255220c1f` or `TAG=a4aa19c608556f7d786852557c36136255220c1f-s390x`
190+
* `SIZE`: size of the pointed-at manifest or index, e.g. `SIZE=1052`
191+
* `HASH`: sha256 hash of the pointed-at manifest or index, e.g. `HASH=66b3d74aeb855f393ddb85e7371a00d5f7994cc26b425825df2ce910583d74dc`
192+
1. Run the command: `notary -s https://notary.docker.io -d ~/.docker/trust addhash -p $IMAGE $TAG $SIZE --sha256 $HASH -r targets/releases`
193+
194+
For example:
195+
196+
```console
197+
IMAGE=docker.io/linuxkit/containerd
198+
TAG=a4aa19c608556f7d786852557c36136255220c1f
199+
SIZE=1052
200+
HASH=66b3d74aeb855f393ddb85e7371a00d5f7994cc26b425825df2ce910583d74dc
201+
notary -s https://notary.docker.io -d ~/.docker/trust addhash -p $IMAGE $TAG $SIZE --sha256 $HASH -r targets/releases
202+
```
203+
204+
##### Getting Size and Hash
205+
206+
There are several ways to get the size and hash of a particular manifest or index. Remember that you are signing a
207+
tag, so you are looking for the size and hash of whatever the tag points to, manifest or index.
208+
209+
* `docker push`
210+
* script
211+
* `manifest-tool`
212+
* `ocidist`
213+
214+
###### docker push
215+
216+
If you pushed the image tag using `docker push`, the very last line of output will give you the hash and size:
217+
218+
```console
219+
$ docker push linuxkit/containerd:a4aa19c608556f7d786852557c36136255220c1f
220+
The push refers to repository [docker.io/linuxkit/containerd]
221+
fce5742422e4: Layer already exists
222+
48a02e7b3096: Layer already exists
223+
4381f8a59bb1: Layer already exists
224+
c0328291406b: Layer already exists
225+
79053b1996f5: Layer already exists
226+
a4aa19c608556f7d786852557c36136255220c1f: digest: sha256:164f6c27410f145b479cdce1ed08e694c9b3d1e3e320c94d0e1ece9755043ea8 size: 1357
227+
```
228+
229+
The first part is the tag you pushed, followed by the keyword `digest`, then the hash, then the size.
230+
231+
##### script
232+
233+
The following script command will provide the output for docker hub. Set the `IMAGE` name and `TAG`
234+
environment variables.
235+
236+
```console
237+
IMAGE=linuxkit/containerd
238+
TAG=v0.8-amd64
239+
jwt=$(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${IMAGE}:pull" | jq -r .token)
240+
curl https://index.docker.io/v2/linuxkit/containerd/manifests/${TAG} -H "Authorization: Bearer ${jwt}" -H "Accept: application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json" -D /dev/stdout -o /dev/null -s
241+
```
242+
243+
##### manifest-tool
244+
245+
The [manifest-tool](https://github.com/estesp/manifest-tool) allows you to inspect manifests, including
246+
both OCI indexes, a.k.a. multi-arch manifests, and simple manifests.
247+
248+
If you inspect the actual tag, you will get just the hash, not the size.
249+
If you inspect an index that includes a manifest that you want, you will get the hash and size.
250+
251+
For example, inspecting just a single arch manifest gives us the hash on the second line, but not the
252+
size:
253+
254+
```console
255+
$ manifest-tool inspect linuxkit/containerd:v0.8-amd64
256+
Name: linuxkit/containerd:v0.8-amd64 (Type: application/vnd.docker.distribution.manifest.v2+json)
257+
Digest: sha256:0dc4f37966e23c0dffa6961119f29100c6d181b221e748c4688a280c08ab52a8
258+
OS: linux
259+
Arch: amd64
260+
# Layers: 5
261+
layer 1: digest = sha256:319073c03e01a960e61913b0e05b4e0094061726f6959732371a1496098c0980
262+
layer 2: digest = sha256:85521c11021aed78da3b61193b3e2cd1f316040eb08744f684cb98fa8ba35dc3
263+
layer 3: digest = sha256:f29bf65845868b4b2adccc661040b939e4119ca5b5cb34cb0583b8b4e279bcc9
264+
layer 4: digest = sha256:95c51328f79f6be125241ba10488e8962bdfd807fe93fc5d4d990eea7ac065e2
265+
layer 5: digest = sha256:794ca16dd5d22f1ccb5f58dea0ef9cb0c95d957ed33af5c4ab008cbdd30c359e
266+
```
267+
268+
While inspecting the index that includes the above tag, gives us the hash but not the size of the
269+
index, but finding the right entry, for example the first one is `amd64`, gives us the size as
270+
`Mfst Length: 1357`:
271+
272+
```console
273+
$ manifest-tool inspect linuxkit/containerd:v0.8
274+
Name: linuxkit/containerd:v0.8 (Type: application/vnd.docker.distribution.manifest.list.v2+json)
275+
Digest: sha256:247e1eb712c2f5e9d80bb1a9ddf9bb5479b3f785a7e0dd4a8844732bbaa96851
276+
* Contains 3 manifest references:
277+
1 Mfst Type: application/vnd.docker.distribution.manifest.v2+json
278+
1 Digest: sha256:0dc4f37966e23c0dffa6961119f29100c6d181b221e748c4688a280c08ab52a8
279+
1 Mfst Length: 1357
280+
1 Platform:
281+
1 - OS: linux
282+
1 - OS Vers:
283+
1 - OS Feat: []
284+
1 - Arch: amd64
285+
1 - Variant:
286+
1 # Layers: 5
287+
layer 1: digest = sha256:319073c03e01a960e61913b0e05b4e0094061726f6959732371a1496098c0980
288+
layer 2: digest = sha256:85521c11021aed78da3b61193b3e2cd1f316040eb08744f684cb98fa8ba35dc3
289+
layer 3: digest = sha256:f29bf65845868b4b2adccc661040b939e4119ca5b5cb34cb0583b8b4e279bcc9
290+
layer 4: digest = sha256:95c51328f79f6be125241ba10488e8962bdfd807fe93fc5d4d990eea7ac065e2
291+
layer 5: digest = sha256:794ca16dd5d22f1ccb5f58dea0ef9cb0c95d957ed33af5c4ab008cbdd30c359e
292+
293+
2 Mfst Type: application/vnd.docker.distribution.manifest.v2+json
294+
2 Digest: sha256:febd923be587826c64db19c429f92a369d6e41d8abb715ff30643250ceafa621
295+
2 Mfst Length: 1357
296+
2 Platform:
297+
2 - OS: linux
298+
2 - OS Vers:
299+
2 - OS Feat: []
300+
2 - Arch: arm64
301+
2 - Variant:
302+
2 # Layers: 5
303+
layer 1: digest = sha256:c35625c316366a48ec51192731e4155191b39fac7848e1b41fa46be1de9d11dc
304+
layer 2: digest = sha256:a73cb03ae4fe7b79bf9ec202ee734a55f962a597b93e9a9625c64e9f2be9e78f
305+
layer 3: digest = sha256:75b2023060fd85e40f4eed9fc5fe60c5b1866d909fc9ea783a21318ec2437e96
306+
layer 4: digest = sha256:413204d4c4ee875fd84dd93799ed1346cfb15e02a508b6306ea7da1a160babc3
307+
layer 5: digest = sha256:cf2293c110f0718e58e01ff4cbafa53eadde280999902fcdcd57269e8ba48339
308+
309+
3 Mfst Type: application/vnd.docker.distribution.manifest.v2+json
310+
3 Digest: sha256:b6adad183487d969059b3badeb5dce032bb449f61607eb024d91cfeabcaf0e57
311+
3 Mfst Length: 1357
312+
3 Platform:
313+
3 - OS: linux
314+
3 - OS Vers:
315+
3 - OS Feat: []
316+
3 - Arch: s390x
317+
3 - Variant:
318+
3 # Layers: 5
319+
layer 1: digest = sha256:16c1054185680ee839fa57dff29f412c179f1739191c12d33ab59bceca28a8ac
320+
layer 2: digest = sha256:e38fe65829ed75127337f18dc2a641e2e9f6c2859a314cf5ac1b7d5022150e26
321+
layer 3: digest = sha256:f2e84a29733f5f17cc860468b94eeeebf378d2a8af9bfc468427b1da430fe927
322+
layer 4: digest = sha256:b38f9350a90499ce01e7704a58b52c90ee28c5562379f7096ce930b5fea160be
323+
layer 5: digest = sha256:cc86a47d79015d074b41a4a3f0918e98dfb13f2fc6ef8def180a81fd36ae2544
324+
```
325+
326+
##### ocidist
327+
328+
[ocidist](https://github.com/deitch/ocidist) is a simple utility to inspect or pull images, manifests,
329+
indexes and individual blobs. If you call `ocidist manifest` and pass it the `--detail` flag, it will
330+
report the hash and size.
331+
332+
For an index:
333+
334+
```console
335+
$ ocidist manifest docker.io/linuxkit/containerd:v0.8 --detail
336+
2020/11/12 11:00:03 ref name.Tag{Repository:name.Repository{Registry:name.Registry{insecure:false, registry:"index.docker.io"}, repository:"linuxkit/containerd"}, tag:"v0.8", original:"docker.io/linuxkit/containerd:v0.8"}
337+
2020/11/12 11:00:03 advanced API
338+
2020/11/12 11:00:06 referenced manifest hash sha256:247e1eb712c2f5e9d80bb1a9ddf9bb5479b3f785a7e0dd4a8844732bbaa96851 size 1052
339+
{
340+
"schemaVersion": 2,
341+
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
342+
"manifests": [
343+
{
344+
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
345+
"size": 1357,
346+
"digest": "sha256:0dc4f37966e23c0dffa6961119f29100c6d181b221e748c4688a280c08ab52a8",
347+
"platform": {
348+
"architecture": "amd64",
349+
"os": "linux"
350+
}
351+
},
352+
{
353+
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
354+
"size": 1357,
355+
"digest": "sha256:febd923be587826c64db19c429f92a369d6e41d8abb715ff30643250ceafa621",
356+
"platform": {
357+
"architecture": "arm64",
358+
"os": "linux"
359+
}
360+
},
361+
{
362+
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
363+
"size": 1357,
364+
"digest": "sha256:b6adad183487d969059b3badeb5dce032bb449f61607eb024d91cfeabcaf0e57",
365+
"platform": {
366+
"architecture": "s390x",
367+
"os": "linux"
368+
}
369+
}
370+
]
371+
}
372+
```
373+
374+
For a single manifest:
375+
376+
```console
377+
$ ocidist manifest docker.io/linuxkit/containerd:v0.8-amd64 --detail
378+
2020/11/12 10:59:08 ref name.Tag{Repository:name.Repository{Registry:name.Registry{insecure:false, registry:"index.docker.io"}, repository:"linuxkit/containerd"}, tag:"v0.8-amd64", original:"docker.io/linuxkit/containerd:v0.8-amd64"}
379+
2020/11/12 10:59:08 advanced API
380+
2020/11/12 10:59:11 referenced manifest hash sha256:0dc4f37966e23c0dffa6961119f29100c6d181b221e748c4688a280c08ab52a8 size 1357
381+
{
382+
"schemaVersion": 2,
383+
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
384+
"config": {
385+
"mediaType": "application/vnd.docker.container.image.v1+json",
386+
"size": 1973,
387+
"digest": "sha256:b11103cf6c84fc3a2968d89e9d6fd7ce9e427380098c17828e3bda27de61ed6a"
388+
},
389+
"layers": [
390+
{
391+
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
392+
"size": 41779632,
393+
"digest": "sha256:319073c03e01a960e61913b0e05b4e0094061726f6959732371a1496098c0980"
394+
},
395+
{
396+
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
397+
"size": 328,
398+
"digest": "sha256:85521c11021aed78da3b61193b3e2cd1f316040eb08744f684cb98fa8ba35dc3"
399+
},
400+
{
401+
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
402+
"size": 176,
403+
"digest": "sha256:f29bf65845868b4b2adccc661040b939e4119ca5b5cb34cb0583b8b4e279bcc9"
404+
},
405+
{
406+
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
407+
"size": 202,
408+
"digest": "sha256:95c51328f79f6be125241ba10488e8962bdfd807fe93fc5d4d990eea7ac065e2"
409+
},
410+
{
411+
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
412+
"size": 300,
413+
"digest": "sha256:794ca16dd5d22f1ccb5f58dea0ef9cb0c95d957ed33af5c4ab008cbdd30c359e"
414+
}
415+
]
416+
}
417+
```
418+
419+
420+
175421
### Build packages as a developer
176422

177423
If you want to develop packages or test them locally, it is best to

0 commit comments

Comments
 (0)