How to get total size of a docker image by docker API properly?
<p>I want to get total size of a docker image by docker API, such as <code>GET /v2/&lt;name&gt;/manifests/&lt;reference&gt;</code> which is described here <a href="https://docs.docker.com/registry/spec/api/#pulling-an-image-manifest" rel="noreferrer">docker spec</a></p>

<p>I got a list of layers with size, such as this <a href="https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#image-manifest" rel="noreferrer">example</a>, I add up these sizes but got a number which is smaller than <code>docker images</code> command show, as i know the docker registry stores these layers files as gzipped tar files, so this sum should be smaller than the size which is showed by <code>docker images</code> command.</p>

<p>How to get the total image size properly by docker API?
I want to get the same size as <code>docker images</code> command show.</p>