Reputation: 2224
Given that I build and tag an image like so:
docker build -t foo:bar .
docker tag foo:bar foo:baz
How can I. later, confirm whether or not the two tags refer to the same thing? I would like to be able to do this through the Registry API (v2), since I might not have both images locally.
Upvotes: 1
Views: 1123
Reputation: 2231
One (tedious?) way of doing that includes comparing the fsLayers
registered in the manifest file attached to each tag:
Download http://your-registry/v2/repo/image/manifests/tag1 and http://your-registry/v2/repo/image/manifests/tag2:
{
"name": "repo/image",
"tag": "tag1",
"architecture": "amd64",
"fsLayers": [{
"blobSum": "sha256:d7958e841d1f103cc24e45cb6108eaf09ecf0b424f071ac6b6ab39241cec293d"
}, {
"blobSum": "sha256:d7958e841d1f103cc24e45cb6108eaf09ecf0b424f071ac6b6ab39241cec293d"
}, {
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
}],
"history": [
(...)
],
"schemaVersion": 1,
"signatures": [{
"header": { (...) },
"signature": "PwuBjXLvQE_DtF29YtyJF2N-zHkVGRh93It4zxL1Igtoi093ykMvXBL_0J6E6-eQVeYrXm3IdDAll-922zeYzQ",
"protected": "eyJmb3JtYXRMZW5ndGgiOjIwOTk0LCJmb3JtYXRUYWlsIjoiQ24wIiwidGltZSI6IjIwMTUtMTItMDdUMTM6NDE6MjJaIn0"
}]
}
Then compare the fsLayers
array. If it is equal between the two manifests, then building a container based on any of these tags will give the same results (i.e. they point to the same thing).
If you have the images locally, comparing the imageId
(via docker inspect
for each tag) is enough and easier. But I don't think that this id can be obtained from the registry.
Upvotes: 2