Reputation: 431
I would like to get the parent of current image using docker registry api v2. Is it possible ?.
I am trying to construct a tree structure of all docker images with parent/child relationship for which I need parent of each docker image. I can get all repositories using GET /v2/_catalog & manifest for each repository by GET /v2//manifests/latest, but I couldn't figure out how to get parent out of it.
Any help would be much appreciated.
Upvotes: 2
Views: 1098
Reputation: 1212
If you examine the manifest of an image you should see blocks of "v1Compatibility" sections in the JSON output.
If you look at those, you should see base image information. For example when I ran this on one of my images, derived from Centos 7:
curl --insecure https://myregistry:5000/v2/imagename/manifests/latest | grep -i centos
I see:
[...]
"v1Compatibility": "{\"id\":\"172ab63cd5e007f8b1dbd7659c2d9520bf9e50755c081f39d171a603ad5d0890\",\"parent\":\"0c908fa575ec22f872f78b12d9e57d132b67a683f7deacd9f02462c546bf52dd\",\"created\":\"2016-04-01T21:28:21.706982438Z\",\"container_config\":{\"Cmd\":[\"/bin/sh -c #(nop) LABEL name=CentOS Base Image vendor=CentOS license=GPLv2 build-date=2016-03-31\"]}}"
"v1Compatibility": "{\"id\":\"3690474eb5b4b26fdfbd89c6e159e8cc376ca76ef48032a30fa6aafd56337880\",\"created\":\"2015-09-07T19:05:48.678585881Z\",\"container_config\":{\"Cmd\":[\"/bin/sh -c #(nop) MAINTAINER The CentOS Project \\[email protected]\\u003e\"]}}"
[...]
Parsing this should give you the information you want.
Upvotes: 3