-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local images ID does not match registry manifest digest #1662
Comments
I will try and answer this question as best as I can and hopefully can get a better understanding of where we are missing documentation. Most of these answers only apply in docker 1.10+ and docker registry 2.3+ since those are the releases in which we made the image identifier content addressable and introduced schema 2 of the manifest used by the registry. When using older versions of docker or the registry the answer may require pulling an image to get the identifier used within docker.
The digest used for docker pull represents the digest of image manifest which is stored in a registry. This digest is considered the root of a hash chain since the manifest itself contains the hash of the content which will be downloaded and imported into docker. See the schema 2 spec for a description of this manifest https://docs.docker.com/registry/spec/manifest-v2-2/. The image id used within docker can be found in this manifest as
The best way to determine this is to compare the image id within a manifest to a local image id. This does require pulling and parsing the manifest.
The reason we do not store the manifest identifier is because we do not store the manifest. It does not make sense to store the manifest since we are not storing the compressed blobs referenced by the manifest. We have taken measures to try and ensure the exact manifest is pushed (cross repository push, caching compressed blob identifiers associated with each layer). We do store the manifest hash when pulling by digest, but this is only a read only value to reference the correct image id in the future without pulling and not exportable since you cannot push by digest. If you have upgraded from an older version of the registry or docker client and do not find these schema 2 manifests to be present in your registry, then repushing images should produce the new manifest. Also a disclaimer that the schema 2 manifests are currently not enabled on the public hub registry. |
Thanks for the detailed answer! But i'm still a bit confused:
I was unable to find this field when i looked at a manifest retrived from a v2 api. I guess this means i'm just running an old registry? I'm using registry:v2 image to run my registry. Essentially what i did in my environment was to look at the docker image id, and then download the manifest for that same image from my registry, and look for the imageid anywhere in that file. It was nowhere in there. You are saying it should be, right? |
@dcowden if the images was pushed with 1.10+ onto a registry 2.3+ then the image id should be in there. If it is a schema 2 manifest (see If you are still seeing issues would be helpful to see the output of the docker commands as well as the manifest in question. |
Yep, that's my problem. I checked, and I have a version 1 schema still. So I think the super-simple answer to my question is: IF you are using a 2.3+ registry and 1.10+, then the manifest contains On Thu, Apr 21, 2016 at 4:21 PM, Derek McGowan [email protected]
|
@dcowden I think that is a fair statement. A schema1 manifest should always produce the same image id but defining the steps to produce directly from the manifest is not straight forward. |
Awesome! Thanks!
|
@dmcgowan thanks for the detailed answer.
Well, that explains why I keep getting So to paraphrase what @dcowden and you said together:
There must be some logic that recreates it. After all, if I do It always is possible to dig into the docker engine source code, but really don't want to go down that path. |
To add to it: When I |
@deitch you will have to |
@RichardScothern so after a Would it make sense for me to rename this issue, "Documentation missing explaining how to reconcile local image ID with registry image ID"? At heart, it sounds like this works, it just needs some clear documentation? |
I thought I remembered an announcement about the public docker registry moving to |
@deitch schema 2 is now enabled. The images you mentioned have not been repushed since then and therefore have not had a schema 2 manifest pushed yet. We do not convert schema 1 manifests to schema 2 on the registry. |
Got it. Is there a library image that is pushed that I can test against? |
hi @deitch , sorry I mislead you there. When a manifest is PUT a |
@deitch try the registry rc candidate, just pushed a few days ago |
@dmcgowan nope. Response to {
"schemaVersion": 1,
"name": "library/registry",
"tag": "2.5.0-rc.1", |
I guess it is possible someone pushed it using an older version of docker? |
@RichardScothern does it matter? I would still need to do a |
I also confirm that trying to GET In fact I also tested pushing a newly built image against a docker-engine version used: $ docker --version
Docker version 1.11.2, build b9f10c9 registry tested: $ docker images registry:2.4
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
registry 2.4 5d322e774cf2 13 days ago 171.5 MB |
@deitch : when you put a manifest, the headers will contain the canonical digest in the registry. If you are using curl to inspect the manifest, you will need this header ( |
Oho! I will try that right now. |
OK, I can confirm that using the header correctly works... but there is a bug. The following works:
The following does not:
According to the RFC (check 2616, although 7231 is more up to date, both say the same thing), multiple options are valid in the Docker registry is more than welcome to ignore the second, third, fourth and any other, they can even be invalid, but the above is a valid header that registry does not recognize and so falls back to v1. |
I've been trying to work out how to do this, and hitting a lot of brick walls. Would anyone be able to share a working |
@tobico see this reply here #1490 (comment). You could curl the registry and docker api and have a digest to compare. Since Docker 1.12 the manifest digest is always being saved, which should allow determining what image is associated with a registry manifest or whether there is an updated image on the registry. |
this needs to be fixed because this has an implication on stack deploy - since local hashes are not computed properly, stack deploy actually recreates each and every service ... even those that havent changed. |
@sandys You're welcome to lobby for a fix in https://github.com/moby/moby, but we can't really fix this here. |
This is really funny. I was doing some work on manifests again, saw the hash differences between manifest and local, and thought I remembered someone opening an issue on it. Did a Google search and came across one opened by... me! 😆 This completely makes sense, and thanks for the help a few years ago @dmcgowan . I can compare the Do you mind explaining how the layers digests work? The digests of layers in the manifest are the digests of the compressed blobs, and that works. On the other hand, the digests of the layers in |
If you're referring to the
As you can see from the above, once you extract the contents of the |
Yep. I had to do some more detailed work on image contents and came across the same. Thanks @adamcohen |
@adamcohen @deitch I'm trying to figure out how to go from the How does the layer.tar hash relate to the final layer id / blob hash for that layer? |
Hey @infogulch |
I put a bounty on this question on stack overflow and got a good answer, though I still had trouble using it for my goal. Maybe you will have more luck: |
Despite having read many of the specs (in flux), I cannot get a clear picture.
If I run
docker images
, I get an image ID for each image. I can get a more detailed result by doingdocker inspect <repo>:<tag>
. E.g. I look atdeitch/mysql-backup:0.7.0
and I get"Id": "sha256:c37d6f99d22771d16b09ec67d29e0f7327b018d4793415acb79d954967249f71"
.If I do
docker pull deitch/mysql-backup:0.7.0
, or if I just use the API andGET https://registry.hub.docker.com/v2/deitch/mysql-backup/manifests/0.7.0
and look at thedocker_content_digest
header, I getsha256:8a069edacec55b930b983a7c740b9802696cdc70acadfa249007950475f033ff
.docker images
ordocker inspect
on the one hand, and the one provided bydocker pull
ordocker_content_digest
header on the other?The text was updated successfully, but these errors were encountered: