Finding the layers and layer sizes for each Docker image

后端 未结 11 1717
自闭症患者
自闭症患者 2020-12-04 06:47

For research purposes I\'m trying to crawl the public Docker registry ( https://registry.hub.docker.com/ ) and find out 1) how many layers an average image has and 2) the si

11条回答
  •  无人及你
    2020-12-04 07:25

    1. https://hub.docker.com/search?q=* shows all the images in the entire Docker hub, it's not possible to get this via the search command as it doesnt accept wildcards.

    2. As of v1.10 you can find all the layers in an image by pulling it and using these commands:

      docker pull ubuntu
      ID=$(sudo docker inspect -f {{.Id}} ubuntu)
      jq .rootfs.diff_ids /var/lib/docker/image/aufs/imagedb/content/$(echo $ID|tr ':' '/')
      

    3) The size can be found in /var/lib/docker/image/aufs/layerdb/sha256/{LAYERID}/size although LAYERID != the diff_ids found with the previous command. For this you need to look at /var/lib/docker/image/aufs/layerdb/sha256/{LAYERID}/diff and compare with the previous command output to properly match the correct diff_id and size.

提交回复
热议问题