NotGlop / docker-drag

Download image from the Docker Hub HTTPS API
GNU General Public License v3.0
675 stars 191 forks source link

Able to tell the calculation document about fake_layerid #9

Closed zhangguanzhang closed 4 years ago

zhangguanzhang commented 4 years ago
    fake_layerid = hashlib.sha256((parentid+'\n'+ublob+'\n').encode('utf-8')).hexdigest()
    layerdir = imgdir + '/' + fake_layerid
    os.mkdir(layerdir)

I used the docker save -o test to find that the fake_layerid is different from the script generated.

NotGlop commented 4 years ago

Yes indeed, that's why I stated it in the README:

Fake layers ID are not calculated the same way than Docker client does (I don't know yet how layer hashes are generated, but it seems deterministic and based on the client)

Do you mean that you know how those hashes are originally calculated? If so, feel free to give some information, I'll implement the change.

Anyway, even with this version of fake_layerid, not relevant of the original Docker client, the image still works, so this shouldn't be a problem.

zhangguanzhang commented 4 years ago

https://github.com/moby/moby/blob/master/image/tarexport/save.go#L294-L329 https://gist.github.com/aaronlehmann/b42a2eaf633fc949f93b#id-definitions-and-calculations maybe could help you

zhangguanzhang commented 4 years ago

and don't support quay.io

NotGlop commented 4 years ago

Just checked it and apparently quay.io uses the old v1 manifest format and doesn't use the v2 yet (that's why it's failing).

We aim to switch it on globally at the end of the year but in case the underlying changes will take longer than expected it would slip to next year.

Source: https://groups.google.com/forum/m/#!topic/quay-sig/lImWndQIrE0

Concerning the fake layer ID, is there any issue when using Docker features? I haven't noticed any until then, but maybe I missed something.
I'll investigate on the Docker save command though.